playMaker

Author Topic: Don't make variable public [SOLVED]  (Read 1309 times)

nFighter

  • Beta Group
  • Full Member
  • *
  • Posts: 174
    • multiplayer adult fighting
Don't make variable public [SOLVED]
« 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;

        }

       
    }
« Last Edit: February 11, 2018, 12:59:11 AM by nFighter »
indie developer of multiplayer adult fighting
http://nakedfighter3d.com

tcmeric

  • Beta Group
  • Hero Member
  • *
  • Posts: 768
Re: Don't make variable public
« Reply #1 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)

tcmeric

  • Beta Group
  • Hero Member
  • *
  • Posts: 768
Re: Don't make variable public
« Reply #2 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;

nFighter

  • Beta Group
  • Full Member
  • *
  • Posts: 174
    • multiplayer adult fighting
Re: Don't make variable public
« Reply #3 on: February 11, 2018, 12:58:55 AM »
Great! Thanks a lot!
indie developer of multiplayer adult fighting
http://nakedfighter3d.com