FANDOM


An object variable allows you to store the contents of a current game object for later use.  

Things like players, enemies, targets,  and weapons are considered objects.  Really, any thing in the game that doesn't fall under other variable types such as Text, Numbers, Vectors, Colors or Boolean would be considered an object.  An important note about storing object variables is any property that is a part of the object also gets stored with an object variable.  This is important because it allows you access to an object and its properties in other brains.

Take a look at the following example.  This is simple brain attached to a 3d Adventurer

http://kodeshare.com/JdQh48

What's going on here is we've defined a Text variable called PlayerName to the Text MyPlayerName.  We then assign a Global Object called PlayerObject to Me.  If you were to then create another logic cube and insert the following kode into the cube, it would display MyPlayerName

http://kodeshare.com/UnM6dQ

This would display the name MyPlayerName as we defined in the first Kode.

One very important thing to note about the practice of assigning one variable to another in project spark is that its a singular event.  Just because you've given it another name, within another scope (Global), doesn't mean its assigned values differ between each variable name.  In this example Global Player Object values will always equal ME.

To test this statement try this test.  Assign a different player name in your new logic cube.  

Meaning, if you turn around and assign another name to player name within that logic cube to something else  then the new player name will apply to both Me/PlayerName and Global PlayerObject/PlayerName.

http://kodeshare.com/UnM6dQ

Ad blocker interference detected!


Wikia is a free-to-use site that makes money from advertising. We have a modified experience for viewers using ad blockers

Wikia is not accessible if you’ve made further modifications. Remove the custom ad blocker rule(s) and the page will load as expected.