PlayMaker Help & Tips > PlayMaker Help

Communication Between JS and FSM's

(1/1)

FlapFail:
Hi there,

PlayMaker really saved my day, but there are a few things that I don't understand.

1. Best practise for any communication between FSM and a JS

I get the thing about SendMessage with any Parameter, but what if I want my script to return any value?
Do I have to set any variable of my FSM in the script like:


--- Code: ---function AddValue ( amount : float ) {

var fsmObject : PlayMakerFSM = gameObject.FindWithTag("AnyFSM").GetComponent.<PlayMakerFSM>();

var currentValue : float = fsmObject.FsmVariables.GetFSMFloat("value").Value + amount;

fsmObject.FsmVariables.GetFSMFloat("value").Value = currentValue;
}
--- End code ---

Is this the way how to do things like this?


2. Call FSM States with custom Values

F.ex. if I got any health manager on a enemy object and I want to affect any damage on it, what if the damage could vary?

I would have a Listener state in my FSM with a transition called "affect damage". If I call this event it would switch to a state with a FloatAdd action.

This would be perfect if I always want to affect a damage with the amount of 5. But what if I want to affect many different damage amounts? Do I need to have a "affect damage amount" var which I have to set always before I call the "affect damage" event?


3. Set a public var of a JS

If I want to set any variable in a Javascript, do I have to make a function like:


--- Code: ---function SetPublicVar ( amount : float) {

myPublicVar = amount;

}

--- End code ---

Or are there any different ways? I saw the get- and set property action, but you cannot access inspector vars of custom scripts, right?


Thanks very much!

Rob



Navigation

[0] Message Index

Go to full version