Playmaker Forum
PlayMaker Help & Tips => PlayMaker Help => Topic started by: nFighter on February 10, 2018, 08:21:25 PM
-
Hi!
I made very simple action to swap game objects. I used a temp variable and I don't want to make it visible in the PlayMaker. How can I do that? (I thought I can make it privat instead of public but in this case the action doesn't work at all.)
public class SwapGameObject : FsmStateAction
{
public FsmGameObject gameObject1;
public FsmGameObject gameObject2;
public FsmGameObject gameObjectTemp;
public override void Reset()
{
gameObject1 = null;
gameObject2 = null;
gameObjectTemp = null;
}
public override void OnEnter()
{
gameObjectTemp.Value = gameObject1.Value;
gameObject1.Value = gameObject2.Value;
gameObject2.Value = gameObjectTemp.Value;
}
}
-
Playmaker actions can accept private variables.
private GameObject gameObjectTemp;
No need to make it a playmaker variable. Just make it a normal unity gameObject variable.
8)
-
PS, you can also just declare a Var as well. It will automatically get the correct variable type for you. (And it will be private)
var gameObjectTemp = gameObject1.Value;
gameObject1.Value = gameObject2.Value;
gameObject2.Value = gameObjectTemp;
-
Great! Thanks a lot!