Game Development Community

Datablock members

by Howard Dortch · in Torque Game Engine · 09/07/2004 (6:12 pm) · 4 replies

I created a couple of players using the same datablock. In the datablock I have a field I added called mydata. As I create each player I would like to put different information in the block like player1.mydata = 10 and player2.mydata = 20. I can't seem to get this to work. Since the data block is shared if I change one I change for both. How can I do this?

#1
09/07/2004 (11:25 pm)
Move the field to the player instances.
#2
09/10/2004 (6:20 am)
So just do %player.mydata =20 sets aglobal for that player?
#3
09/10/2004 (7:36 am)
Aye Howard, but be careful where the %player is coming in from. I have been doing some with these at the moment and find some places it sends the player and some the datablock, but more often the player reference. Usually first thing I do in a function I want to manipulate a variable I calle %player.dump(); and run it once to see all the functions and variables available there. If you get it and it doesn't list your variable then try %player.dataBlock.dump(); and good chance it will be there. Watch the capitolization on dataBlock though, I got hung up there a few times. =)
#4
09/11/2004 (7:44 am)
It's not a global - it's a variable specific to that instance of the player. If you wanted a global you'd do something like:
$myData = 100;