playMaker

Author Topic: Set FSM Bool not working if using global gameobject  (Read 6555 times)

jess84

  • Hero Member
  • *****
  • Posts: 515
Set FSM Bool not working if using global gameobject
« on: June 20, 2014, 04:12:06 PM »
Just spent an hour tracking this down in my project...

I was using a 'Set FSM Bool' action, and had selected a global gameobject variable from the dropdown, plus the FSM name and Variable name. It should have worked - but just wouldn't.

I then changed it from a global gameobject on the dropdown, and dragged my target gameobject onto the action. It then worked.

I can't see that anything was setup incorrectly. My gameobject was assigned in the playmaker global window (and was fine during runtime), and it could find it - and give me my FSM/variables.

So I'm guessing this action doesn't fully work as intended.

Alex Chouls

  • Administrator
  • Hero Member
  • *****
  • Posts: 3999
  • Official Playmaker Support
    • LinkedIn
Re: Set FSM Bool not working if using global gameobject
« Reply #1 on: June 20, 2014, 04:32:25 PM »
Quote
My gameobject was assigned in the playmaker global window

Global variables are an asset like prefabs. They cannot store references to scene objects. To reference a scene object you have to find it at runtime and store it in the global variable.

The globals window shouldn't have let you assign the gameobject - that is fixed in the next update... along with better feedback about these limitations in Unity.

jess84

  • Hero Member
  • *****
  • Posts: 515
Re: Set FSM Bool not working if using global gameobject
« Reply #2 on: June 20, 2014, 04:52:31 PM »
It's not really a scene object though, it's a gameobject prefab that I'm trying to reference.

And it works perfectly if I drop my prefab in, it doesn't work if I select a global variable. (this is a global variable that I've already linked to my prefab before runtime).

See the screenshot.

Is this really the desired behaviour?

Alex Chouls

  • Administrator
  • Hero Member
  • *****
  • Posts: 3999
  • Official Playmaker Support
    • LinkedIn
Re: Set FSM Bool not working if using global gameobject
« Reply #3 on: June 20, 2014, 05:27:05 PM »
If you hit Debug in the actions panel, you'll see that the contents of the global variable is probably "none". The global variable points to a scene object, but it cannot save/load a reference to that scene object. So you need to find the gameobject at runtime and set the global variable value.

jess84

  • Hero Member
  • *****
  • Posts: 515
Re: Set FSM Bool not working if using global gameobject
« Reply #4 on: June 20, 2014, 05:53:42 PM »
It already knows the global gameobject as I've set that in the global variable window already.

Here's with debug on.


jess84

  • Hero Member
  • *****
  • Posts: 515
Re: Set FSM Bool not working if using global gameobject
« Reply #5 on: June 20, 2014, 05:56:14 PM »
And just to confirm, both the object that the FSM is on, and the target object are both created from prefabs.


jess84

  • Hero Member
  • *****
  • Posts: 515
Re: Set FSM Bool not working if using global gameobject
« Reply #6 on: June 20, 2014, 06:01:40 PM »
And this is during runtime:

Alex Chouls

  • Administrator
  • Hero Member
  • *****
  • Posts: 3999
  • Official Playmaker Support
    • LinkedIn
Re: Set FSM Bool not working if using global gameobject
« Reply #7 on: June 20, 2014, 07:27:31 PM »
I'm not at my computer right now, but I'll try to repro when I am...
« Last Edit: June 20, 2014, 07:29:47 PM by Alex Chouls »

jess84

  • Hero Member
  • *****
  • Posts: 515
Re: Set FSM Bool not working if using global gameobject
« Reply #8 on: June 20, 2014, 07:51:10 PM »
Great, thanks.

BTW, I didn't know about that Debug option - that's bloody useful! And probably would have saved me lots of faffing around in the past :)

(I'd probably suggest that enabled by default, so other noobs don't miss it!)

jess84

  • Hero Member
  • *****
  • Posts: 515
Re: Set FSM Bool not working if using global gameobject
« Reply #9 on: June 23, 2014, 07:49:17 AM »
Hi Alex,

Did you confirm whether this  was a bug?

Alex Chouls

  • Administrator
  • Hero Member
  • *****
  • Posts: 3999
  • Official Playmaker Support
    • LinkedIn
Re: Set FSM Bool not working if using global gameobject
« Reply #10 on: June 23, 2014, 10:24:44 AM »
I'm having a hard time reproducing the problem here...

Any chance you could build a small project that shows the problem and email it to me?

Is the referenced prefab in the same hierarchy as the first prefab?
Unity does some magic fixup on object references within prefab hierarchies. This won't happen to object references in global variables - they will still point to the prefab, NOT a prefab instance. This may be what you're seeing... but it would be nice to have a small repro project to be sure...

jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 15500
  • Official Playmaker Support
Re: Set FSM Bool not working if using global gameobject
« Reply #11 on: July 21, 2014, 08:22:42 AM »
Hi,

 could it be linked somehow to the but I found earlier on today that if you come back to a state with a SetFsmXXX and you are trying to access a different fsm, it will fail?


 Bye,

 Jean