Playmaker Forum

PlayMaker News => General Discussion => Topic started by: Melonwars on January 20, 2014, 06:30:57 AM

Title: Global Variable assigned to Object
Post by: Melonwars on January 20, 2014, 06:30:57 AM
Hello everybody,

I'm looking for a solution to the topic local/global variables.

I have several prefab cameras observing a game object. Each camera makes different "observations", e.g. records the game object's position. Now, each camera gets an observation different from the other camera in the scene. Nevertheless, each camera needs the data from all others.

With local variables this is not possible, moreover, I need to read them in a C# script.
If I use a global, each camera all the time overwrites the value.

Any ideas? I would be very grateful!
Title: Re: Global Variable assigned to Object
Post by: Lane on January 20, 2014, 07:09:31 AM
You can do it with local variables, just send or get the variables onto a proxy object that holds them. Probably more complicated this way but it works fine, I don't use globals at all.

I don't really understand your last part about the camera overwriting the variables. If you want the data constantly up to date then of course its going to overwrite the variable. You'll have to do some sort of work with it then store the result as a different variable so you don't inject bad data into the chain you're using to compute that data.