Playmaker Forum

PlayMaker Help & Tips => PlayMaker Help => Topic started by: artician on May 20, 2014, 08:40:04 PM

Title: Two prefabs accessing global variables cause bugs
Post by: artician on May 20, 2014, 08:40:04 PM
In, what was supposed to be, a small side-project, I have a bit of an issue.

I have two versions of a player character that use different methods of locomotion.  I did this experimentally to try and see what would work best. 

One player character is using only dynamic physics for its motion: rigidbodies affected by gravity, and driven by forces and torque.
The other is driven by kinematics/direct translation in code (move n-units in Z+ direction per-second).

I started with the dynamic one, and it wasn't looking like it would work, so I made a prefab as a way of saving my work and put it aside.  I deleted it out of my scene to start over.

Then I made the second, kinetically-driven character.  It was also not to my satisfaction, however I had some new ideas about making the dynamic character work, so I decided to switch back to test my ideas.  I made a second prefab to save the second kinematic character, and deleted it out of my scene to put the dynamic-prefab back in for testing.

Please keep in mind two things:
1) I am using global variables for almost all data for the player, so other FSMs can easily access it.
2) None of these global variables has changed *at all*.  Not even their assigned values.

I loaded in the dynamic character prefab for further development.  At first it worked in runtime.  Then I got an error, and suddenly the character could not move forward.  Then I got two more errors and the character was unable to turn.  I looked at the states on the character prefab to see what changed, and saw that the variables assigned for those operations were now set to "None". 
I looked at the global variables that stored those values, and at first it looked like they had been deleted.  Upon closer inspection I noticed that they were not deleted, but they were "renamed" to a blank string (so I now had two unnamed global variables where, I assume, the two global variables storing my characters movement values were). 

So somehow these variables were 1) renamed, and 2) disconnected from the actions that used them.  I don't know what I can do to help you fix this, and I don't know if I can give any further information about my project, so I just hope the information that I've shared will let you troubleshoot and fix it.
Thanks.
Title: Re: Two prefabs accessing global variables cause bugs
Post by: 1982 on May 22, 2014, 05:56:30 AM
Same has happened to me one or two occasions, I don't really know the reason behind it. All you can do now is delete your blank global variables, and make completely new ones preferably with new names.
Title: Re: Two prefabs accessing global variables cause bugs
Post by: artician on May 22, 2014, 05:45:33 PM
Yeeaahhh...   but deleting Global Variables breaks baby-Jesus' heart!  ;)