Playmaker Forum

PlayMaker Help & Tips => PlayMaker Help => Topic started by: nFighter on February 10, 2018, 08:21:25 PM

Title: Don't make variable public [SOLVED]
Post 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.)

Code: [Select]
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;

        }

       
    }
Title: Re: Don't make variable public
Post by: tcmeric on February 10, 2018, 08:45:48 PM
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)
Title: Re: Don't make variable public
Post by: tcmeric on February 10, 2018, 08:47:38 PM
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;
Title: Re: Don't make variable public
Post by: nFighter on February 11, 2018, 12:58:55 AM
Great! Thanks a lot!