Playmaker Forum
Bug Reporting => PlayMaker Bug Reporting => Topic started by: jess84 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.
-
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.
-
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?
-
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.
-
It already knows the global gameobject as I've set that in the global variable window already.
Here's with debug on.
-
And just to confirm, both the object that the FSM is on, and the target object are both created from prefabs.
-
And this is during runtime:
-
I'm not at my computer right now, but I'll try to repro when I am...
-
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!)
-
Hi Alex,
Did you confirm whether this was a bug?
-
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...
-
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