Playmaker Forum

PlayMaker Help & Tips => PlayMaker Help => Topic started by: nFighter on February 11, 2018, 01:15:53 AM

Title: Prefab reference to Global Variable - Playmaker ruined the project
Post by: nFighter on February 11, 2018, 01:15:53 AM
I know that Unity have some weird restriction for Prefab referencing to Scene Objects... But, I have a global variable that referencing to scene objects and I use it in prefabs and everything works fine. I save and load project, open different scenes, build it and it works perfectly. Except when Playmaker realize that I'm referencing to scene objects with this variables it flooded me with tons of red alerts and all this alarm mood.

What am I doing wrong? I mean, if the referencing to scene objects from prefab really works this way, why can't I do it?

And is it possible to ask Playmaker stop the panic?
I found the option "Check for prefab restriction" and looks like the panic level goes down. But I'm still interested why is it wrong and should I care? Did it already sent a complain to Unity's headquarter: someone use me in a prohibited way?
Title: Re: Prefab reference to Global Variable
Post by: djaydino on February 11, 2018, 07:21:25 AM
Hi.
Can you show some images or a video from your prefab fsm / the global used and scene fsm that sets the gameobject to the global.
And from the errors you are getting.
Title: Re: Prefab reference to Global Variable
Post by: nFighter on February 11, 2018, 02:13:28 PM
Sure. Here I define the global variables.
(https://i.snag.gy/OfJbVw.jpg)

And here is a prefab referencing to it
(https://snag.gy/d4hL3w.jpg)
Title: Re: Prefab reference to Global Variable
Post by: nFighter on February 11, 2018, 02:36:13 PM
And now the most interesting part: Playmaker ruined my whole project somehow!

1. One of my global variables was renamed without my intention. If you check the screenshots from my last post you can see a variable CharShape and that's not what I did. I have 4 variables started with A_ and 4 started with B_. Now one of the A_ renamed to CharShape. (Is it even possible to rename Global Variable? I don't know how to do it, but playmaker just did)

2. In some places of the project Playmaker create local variable with the same name and reference to it. Not everywhere, just in some random places. Look, it's local now. Yesterday it was a global and it name was different. It was one of the  "A_". (https://snag.gy/4mTrit.jpg)

3. Yesterday I did many tests with save/load scene, exit/start unity and building the project. It was working perfectly, today it's totally ruined. What's going on an how it's even possible? Is it penalty from Unity's headquarter for misusing the global variables?
Title: Re: Prefab reference to Global Variable - Playmaker ruined the project
Post by: antibob on February 11, 2018, 05:17:55 PM
If you think P.M. killed your project, delete any Playmaker reference in your project folder and reinstall P.M.

It's best to connect prefabs with game objects (and variables) by finding GameObject dynamically by name or tag.
Title: Re: Prefab reference to Global Variable - Playmaker ruined the project
Post by: tcmeric on February 11, 2018, 09:37:28 PM
Backup the project before you delete anything. Which version of unity and playmaker are you currently using?
Title: Re: Prefab reference to Global Variable - Playmaker ruined the project
Post by: nFighter on February 11, 2018, 11:45:05 PM
I'm using Unity 2017.3.0f3 and Playmaker 1.8.5

For now I just eliminate most of my Prefabs and working directly with cloning objects in scene. I don't understand what's happened but will avoid using PM with prefabs as much as possible  :-\
Title: Re: Prefab reference to Global Variable - Playmaker ruined the project
Post by: djaydino on February 12, 2018, 04:07:12 AM
Hi,
Maybe this tutorial can help you :

Title: Re: Prefab reference to Global Variable - Playmaker ruined the project
Post by: jeanfabre on February 22, 2018, 05:23:33 AM
Hi,

 Also, did you actually named global variables the same as some local variables? This is a known issue that there will be clash in logic if an fsm tries to use a global variable named the same as one of its local variable. But it should not rename any variables...

 Bye,

 Jean
Title: Re: Prefab reference to Global Variable - Playmaker ruined the project
Post by: Fat Pug Studio on February 22, 2018, 05:40:35 AM
Generally, avoid that kind of workflow if you don't want mess to occur. Instantiate objects which are populated with data and properties on runtime and work with local references and variavles as much as possible.