playMaker

Show Posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.


Topics - beowulfkaine

Pages: [1]
1
Playmaker Help / Launching object with force?
« on: September 14, 2017, 12:45:08 PM »
Hello, hopefully, someone may be able to help me.

I have an animation of a creature picking up a rock and throwing it.  I'm having a hard time trying to figure out the mechanics.  Is there a simple way for an object to be created in his and then at a certain frame have it launch based on the direction it was thrown?

2
Playmaker Help / Ragdoll Workflow?
« on: July 29, 2017, 01:24:10 AM »
Looking everywhere and I can't find it.  Simple question for some, essentially I  have a character that has a ragdoll prefab as well. I want to know what the step by step workflow is to go from his mechanism animation to a ragdoll state? Is it possible to get the force hitting the object to be applied to the ragdoll as well throwing it in the air? I appreciate your help!

Thanks in advance!

3
Action Requests / Anyone know how to make an action for this script?
« on: July 23, 2017, 04:13:04 PM »
Hello!

Ok, I have this script (below) and I wanted to know if anyone knew how to make this into an action that "happens" when an fsm is activated or event triggered(more likely)?  Currently, the controller has to be over the object in order for this to work and the trigger pressed or not pressed, but it works on a collider system. I would like instead of physically being over the object to be activated by trigger within playmaker.  Is this possible? I can't read c# very well or enough really to understand how this script works. Any help would be great!

Code: [Select]
//======= Copyright (c) Valve Corporation, All rights reserved. ===============
//
// Purpose: Handles the spawning and returning of the ItemPackage
//
//=============================================================================

using UnityEngine;
using System.Collections;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using UnityEngine.Events;
#if UNITY_EDITOR
using UnityEditor;
#endif

namespace Valve.VR.InteractionSystem
{
//-------------------------------------------------------------------------
[RequireComponent( typeof( Interactable ) )]
public class ItemPackageSpawner : MonoBehaviour
{
public ItemPackage itemPackage
{
get
{
return _itemPackage;
}
set
{
CreatePreviewObject();
}
}

public ItemPackage _itemPackage;

private bool useItemPackagePreview = true;
private bool useFadedPreview = false;
private GameObject previewObject;

public bool requireTriggerPressToTake = false;
public bool requireTriggerPressToReturn = false;
public bool showTriggerHint = false;

[EnumFlags]
public Hand.AttachmentFlags attachmentFlags = Hand.defaultAttachmentFlags;
public string attachmentPoint;

public bool takeBackItem = false; // if a hand enters this trigger and has the item this spawner dispenses at the top of the stack, remove it from the stack

public bool acceptDifferentItems = false;

private GameObject spawnedItem;
private bool itemIsSpawned = false;

public UnityEvent pickupEvent;
public UnityEvent dropEvent;

public bool justPickedUpItem = false;


//-------------------------------------------------
private void CreatePreviewObject()
{
if ( !useItemPackagePreview )
{
return;
}

ClearPreview();

if ( useItemPackagePreview )
{
if ( itemPackage == null )
{
return;
}

if ( useFadedPreview == false ) // if we don't have a spawned item out there, use the regular preview
{
if ( itemPackage.previewPrefab != null )
{
previewObject = Instantiate( itemPackage.previewPrefab, transform.position, Quaternion.identity ) as GameObject;
previewObject.transform.parent = transform;
previewObject.transform.localRotation = Quaternion.identity;
}
}
else // there's a spawned item out there. Use the faded preview
{
if ( itemPackage.fadedPreviewPrefab != null )
{
previewObject = Instantiate( itemPackage.fadedPreviewPrefab, transform.position, Quaternion.identity ) as GameObject;
previewObject.transform.parent = transform;
previewObject.transform.localRotation = Quaternion.identity;
}
}
}
}


//-------------------------------------------------
void Start()
{
VerifyItemPackage();
}


//-------------------------------------------------
private void VerifyItemPackage()
{
if ( itemPackage == null )
{
ItemPackageNotValid();
}

if ( itemPackage.itemPrefab == null )
{
ItemPackageNotValid();
}
}


//-------------------------------------------------
private void ItemPackageNotValid()
{
Debug.LogError( "ItemPackage assigned to " + gameObject.name + " is not valid. Destroying this game object." );
Destroy( gameObject );
}


//-------------------------------------------------
private void ClearPreview()
{
foreach ( Transform child in transform )
{
if ( Time.time > 0 )
{
GameObject.Destroy( child.gameObject );
}
else
{
GameObject.DestroyImmediate( child.gameObject );
}
}
}


//-------------------------------------------------
void Update()
{
if ( ( itemIsSpawned == true ) && ( spawnedItem == null ) )
{
itemIsSpawned = false;
useFadedPreview = false;
dropEvent.Invoke();
CreatePreviewObject();
}
}


//-------------------------------------------------
private void OnHandHoverBegin( Hand hand )
{
ItemPackage currentAttachedItemPackage = GetAttachedItemPackage( hand );

if ( currentAttachedItemPackage == itemPackage ) // the item at the top of the hand's stack has an associated ItemPackage
{
if ( takeBackItem && !requireTriggerPressToReturn ) // if we want to take back matching items and aren't waiting for a trigger press
{
TakeBackItem( hand );
}
}

if ( !requireTriggerPressToTake ) // we don't require trigger press for pickup. Spawn and attach object.
{
SpawnAndAttachObject( hand );
}

if ( requireTriggerPressToTake && showTriggerHint )
{
ControllerButtonHints.ShowTextHint( hand, Valve.VR.EVRButtonId.k_EButton_SteamVR_Trigger, "PickUp" );
}
}


//-------------------------------------------------
private void TakeBackItem( Hand hand )
{
RemoveMatchingItemsFromHandStack( itemPackage, hand );

if ( itemPackage.packageType == ItemPackage.ItemPackageType.TwoHanded )
{
RemoveMatchingItemsFromHandStack( itemPackage, hand.otherHand );
}
}


//-------------------------------------------------
private ItemPackage GetAttachedItemPackage( Hand hand )
{
GameObject currentAttachedObject = hand.currentAttachedObject;

if ( currentAttachedObject == null ) // verify the hand is holding something
{
return null;
}

ItemPackageReference packageReference = hand.currentAttachedObject.GetComponent<ItemPackageReference>();
if ( packageReference == null ) // verify the item in the hand is matchable
{
return null;
}

ItemPackage attachedItemPackage = packageReference.itemPackage; // return the ItemPackage reference we find.

return attachedItemPackage;
}


//-------------------------------------------------
private void HandHoverUpdate( Hand hand )
{
if ( requireTriggerPressToTake )
{
if ( hand.controller != null && hand.controller.GetHairTriggerDown() )
{
SpawnAndAttachObject( hand );
}
}
}


//-------------------------------------------------
private void OnHandHoverEnd( Hand hand )
{
if ( !justPickedUpItem && requireTriggerPressToTake && showTriggerHint )
{
ControllerButtonHints.HideTextHint( hand, Valve.VR.EVRButtonId.k_EButton_SteamVR_Trigger );
}

justPickedUpItem = false;
}


//-------------------------------------------------
private void RemoveMatchingItemsFromHandStack( ItemPackage package, Hand hand )
{
for ( int i = 0; i < hand.AttachedObjects.Count; i++ )
{
ItemPackageReference packageReference = hand.AttachedObjects[i].attachedObject.GetComponent<ItemPackageReference>();
if ( packageReference != null )
{
ItemPackage attachedObjectItemPackage = packageReference.itemPackage;
if ( ( attachedObjectItemPackage != null ) && ( attachedObjectItemPackage == package ) )
{
GameObject detachedItem = hand.AttachedObjects[i].attachedObject;
hand.DetachObject( detachedItem );
}
}
}
}


//-------------------------------------------------
private void RemoveMatchingItemTypesFromHand( ItemPackage.ItemPackageType packageType, Hand hand )
{
for ( int i = 0; i < hand.AttachedObjects.Count; i++ )
{
ItemPackageReference packageReference = hand.AttachedObjects[i].attachedObject.GetComponent<ItemPackageReference>();
if ( packageReference != null )
{
if ( packageReference.itemPackage.packageType == packageType )
{
GameObject detachedItem = hand.AttachedObjects[i].attachedObject;
hand.DetachObject( detachedItem );
}
}
}
}


//-------------------------------------------------
private void SpawnAndAttachObject( Hand hand )
{
if ( hand.otherHand != null )
{
//If the other hand has this item package, take it back from the other hand
ItemPackage otherHandItemPackage = GetAttachedItemPackage( hand.otherHand );
if ( otherHandItemPackage == itemPackage )
{
TakeBackItem( hand.otherHand );
}
}

if ( showTriggerHint )
{
ControllerButtonHints.HideTextHint( hand, Valve.VR.EVRButtonId.k_EButton_SteamVR_Trigger );
}

if ( itemPackage.otherHandItemPrefab != null )
{
if ( hand.otherHand.hoverLocked )
{
//Debug.Log( "Not attaching objects because other hand is hoverlocked and we can't deliver both items." );
return;
}
}

// if we're trying to spawn a one-handed item, remove one and two-handed items from this hand and two-handed items from both hands
if ( itemPackage.packageType == ItemPackage.ItemPackageType.OneHanded )
{
RemoveMatchingItemTypesFromHand( ItemPackage.ItemPackageType.OneHanded, hand );
RemoveMatchingItemTypesFromHand( ItemPackage.ItemPackageType.TwoHanded, hand );
RemoveMatchingItemTypesFromHand( ItemPackage.ItemPackageType.TwoHanded, hand.otherHand );
}

// if we're trying to spawn a two-handed item, remove one and two-handed items from both hands
if ( itemPackage.packageType == ItemPackage.ItemPackageType.TwoHanded )
{
RemoveMatchingItemTypesFromHand( ItemPackage.ItemPackageType.OneHanded, hand );
RemoveMatchingItemTypesFromHand( ItemPackage.ItemPackageType.OneHanded, hand.otherHand );
RemoveMatchingItemTypesFromHand( ItemPackage.ItemPackageType.TwoHanded, hand );
RemoveMatchingItemTypesFromHand( ItemPackage.ItemPackageType.TwoHanded, hand.otherHand );
}

spawnedItem = GameObject.Instantiate( itemPackage.itemPrefab );
spawnedItem.SetActive( true );
hand.AttachObject( spawnedItem, attachmentFlags, attachmentPoint );

if ( ( itemPackage.otherHandItemPrefab != null ) && ( hand.otherHand.controller != null ) )
{
GameObject otherHandObjectToAttach = GameObject.Instantiate( itemPackage.otherHandItemPrefab );
otherHandObjectToAttach.SetActive( true );
hand.otherHand.AttachObject( otherHandObjectToAttach, attachmentFlags );
}

itemIsSpawned = true;

justPickedUpItem = true;

if ( takeBackItem )
{
useFadedPreview = true;
pickupEvent.Invoke();
CreatePreviewObject();
}
}
}
}

4
Playmaker Help / Action to Break Prefab Instance?
« on: July 19, 2017, 01:47:15 PM »
Hello! I want to know if there is an action or way to break a prefab instance after a certain time or (xxxx) happens?

5
VR Help / Desperately Need Help with SteamVR WorkFlow
« on: July 18, 2017, 01:35:01 PM »
Hello!

Ok, I'm having problems with a workflow and I'm not sure if anyone can help me but here goes.

I'm using STEAM VR and essentially what happens when using the Bow and Arrow example scene is that the arrow instantiated is a clone made from the original game object.  Now that is all and good, however, in my application, I have 4 options to change the arrow that is displayed, which works sort of. The problem is, when the new arrow is instantiated, it is the original arrow that is made a clone of.  I've been trying to change the variable of the arrow itself, which only works until the arrow is fired, then a new clone is made and poof, back to square one. 

I tried to modify the original object, which does work, however, the clone seems to be not updating from the original object.  It looks as if the script clones the ArrowHand game object, then after being fired only uses the clone of the cloned object as a reference and doesn't go back to the original object for reference.  I don;t know any c# so I don't exactly understand where it's keeping the Cloned clone.  I'm including the scripts and a sample scene, though I'm not sure how much of the sample scene may be missing (if you download steam VR plugin it may fill in the missing prefabs.

I'm including scripts and a scene file.

6
Playmaker Help / Possible to change tag of parent?
« on: July 08, 2017, 02:06:32 PM »
I was wondering if this is possible:

I have an arrow that has a bunch of varieties within its hierarchy, I cannot make these into separate prefabs for various reasons.  I can enable and disable the sub-arrows but I also need the parent tag that holds all the arrows to change.

Example:

Ice arrow is enabled, Parent Tag changes to Ice Arrow
Fire arrow is enabled, Parent tag is changed to Fire Arrow.

I also need this to be on an individual basis, so the tag cannot change on the entire prefab otherwise the arrows would change type in mid-flight.

Is this possible?

7
Playmaker Help / Playmaker and Ragdolls
« on: July 02, 2017, 04:36:59 PM »
Hey, everyone, I've been looking around and I'm not sure if I'm just looking for the wrong search topic or what, so sorry if its covered somewhere I missed it.  Essentially I want to have my NPC running then when he gets hit with a collider have him turn into a ragdoll.  Ideally, if it's possible to get the last frame of his animation and use that as the base of the ragdoll falling position.

8
Playmaker Help / Help getting value from script...[SOLVED]
« on: June 11, 2017, 02:27:23 PM »
Hello everyone! I was wondering if someone can help me with this.  I am NOT a coder, this script is from the Advanced Battle AI system that's free on the asset store.  Essentially I want to be able to get the "currenthealth"

Code: [Select]
using UnityEngine;
using System.Collections;


public class health : MonoBehaviour {
//max health. you set this to what you want his health to be
public int maxhealth=50;
public int currenthealth;
//cant die
public bool invincible;
public bool dead;
//check if ou want to enable health regeneration
public bool regenerate;
//time between each generate
public float regenerationtime=0.8f;
//the timer
private float regtimer;
//amount of hp to regenerate per generate
public int regenerationamount=2;
private int healthsave;
public bool givereward;
private bool rewardgiven;
public int xptogive=10;
public int goldtogive=10;


// Use this for initialization
void Start () {
givereward=true;

AI ai=(AI)GetComponent("AI");
if(ai) ai.health=maxhealth;

currenthealth=maxhealth;
healthsave=maxhealth;
}

// Update is called once per frame
void Update () {



//tell ai when health is changed
if(healthsave>currenthealth|healthsave<currenthealth){
AI ai=(AI)GetComponent("AI");
if(ai){
ai.health=currenthealth;
healthsave=currenthealth;
}
}

//death
if(dead){
AI ai=(AI)GetComponent("AI");
//tell ai that he is dead
if(ai)ai.dead=true;
}
else givereward=true;

if(currenthealth>=maxhealth) currenthealth=maxhealth;

//if health is less than zero
if(currenthealth<=0){
//check if invincible if not death
if(invincible)dead=false;
else dead=true;
currenthealth=0;
}
//regenerate
if(regenerate){
if(currenthealth<maxhealth&currenthealth>0){
regtimer+=Time.deltaTime;
if(regtimer>regenerationtime){
currenthealth=currenthealth+regenerationamount;
regtimer=0;
}

}
}
}
}

I want to be able to pass the currenthealth value to an fsm variable that I can then check to see if 0 then I can do anything else that I want with it.  But the checking the value thing is getting me stumped.

Also the XPtogive and the Goldtogive as well.  Is it possible to have this value also take away instead of giving?  An example is if an enemy kills this AI then xp is taken away, or anything else I choose.

Here is my intended use:

I have two armies that are fighting each other. Each uses the same AI script, my concept is that when an enemy dies gold is given when an ally dies gold is taken away.  The gold is then set as a value that can be used later for like power-ups ect..

Your fighting along allies and everything you kill garners gold as well as your allies.  But if your army gets overwhelmed, then the gold starts depleting and you end up losing because you can afford to repair your castle or buy new stuff, ect..

9
Playmaker Help / Need help with elevator FSM workflow
« on: May 09, 2017, 03:58:34 PM »
Hello!

Ok so here's my problem, I'm using PM with vr but I can't imagine it being much different.  Essentially I have 4 floors, an elevator with 4 button and I'd like to have the player select which button to press and go to that floor. I would like for the other. Utto s to be disabled so they can't bounce back and forth.

I've tried several variations and after 2 days, I'm admitting I need some help on this workflow. Anyone have any ideas?

10
Playmaker Help / Is there a enable/disable multiple FSM action?
« on: May 08, 2017, 06:24:47 PM »
I'd like to be able to enable and disable fsms from the same action if possible, is there anything like that around?

11
Playmaker Help / Is there a "Bool Any False"?
« on: April 26, 2017, 08:17:34 PM »
Hey I was wondering if I'm just missing it, but I'm looking for an action like "Bool Any True" but for it to be "Bool Any False". Basically the opposite of this action

I basically want it to check to see if anything has changed to false, if so to fire an event, but I cant seem to find it?

12
I'm new to playmaker and not much of a coder (the reason why I'm using PLaymaker)  I bought the SteamVR playmaker asset but I've been having trouble for weeks trying to figure it out.

This is all I want to do:

I want to make a light switch. I want either controller to be able to do it and I would like for it to store either a variable or a boole (if its on or off and possible a value for other things) a simple on or off with a sound.

Can anyone help me? I'm at my wits end, ELI5 please.


13
Playmaker Help / Increase Zoom of Playmaker work flow Icons?
« on: April 19, 2017, 07:42:05 AM »
Is there a way to Increase Zoom of Playmaker work flow Icons? In the playmaker area where you make the actions, I can't zoom in closer then a certain amount.  Is there a way to make them bigger or allow for even further zooming?

14
VR Help / Need help with a type of action for HTC Vive
« on: April 15, 2017, 02:14:51 PM »
Ok, so I'm not sure if I'm going to explain this correct but here goes:

I am making a Breaker box fuse puzzle. The puzzle is pretty simple, there is a breaker box and inside there are lets say 20 breakers of various AMP's. However there are 4 breakers that are either busted or missing.  The goal of the player is to find the 4 appropriate breakers in the room and replace or insert them in the correct slot.

So 4 slots, 4 breakers each 10/20/30/40 amps respectively. Player can mix and match the breakers in any slot and flip the breakers on one by one, but if the variable sent to the Boolean does not equal a certain number, then the check fails and  when the player pulls the main switch all the breakers blow and the animation is played for the down switch on each breaker.

My issue is how can I create the flow in PM that the player can pick up a breaker, parent it to either hand rotated correctly, allow the player to flip the switch on or off (in place or not) have the breaker snap to the position needed when the "button" whichever is used, and allow the player to pull out the breaker to test it in another spot if it does indeed fail?

I hope I explained what I am trying to do correctly, any help would be really appreciated!

15
Sorry if this is covered somewhere but I can't find anything on this, I'm looking to find information on how to use Playmaker and Unity4.3 with the new 2D features found in Unity.  All I can find is the old style tutorials which are not helpful with the new system.  I can't even figure out how to make a simple idle/walk animation using a sprite sheet created in 4.3, all there is are the old info using quads.  Has anyone done this yet, can you point me in a direction on the process?


Pages: [1]