My ultimate datablock questions.
by Kyrah Abattoir · in Torque 3D Professional · 09/01/2011 (4:38 am) · 1 replies
Here are a few questions i'm hoping to get answers to about datablocks.
As far as i understand, any value that is declared in a datablock is immuable. Right?
So if i set a model for an object through the object's datablock it's impossible to change it Right?
-If you override a datablock with another, by declaring a new datablock with the same name, are the changes broadcasted to the client?
-Is there a way to skip datablock transfering from the server to the client on connection, like, if your game include tousand of them, it seems to be a bit silly to transfer them at every connection if you can have local copies on the client.
-Is there a way to skip on using datablocks, yet not need to transfer the object parameters to the client, having the "primordial" version of the object cached on the client and then only sending to the client what is different from this primordial template.
-If you set a transform in the datablock, does that mean the object can never move?, that you can never set a transform on it? or that it's simply the "default" position.
-Is there a way to make a datablock in such a way that it set the default value for certain parameters but that they can still be changed by the server?
As far as i understand, any value that is declared in a datablock is immuable. Right?
So if i set a model for an object through the object's datablock it's impossible to change it Right?
-If you override a datablock with another, by declaring a new datablock with the same name, are the changes broadcasted to the client?
-Is there a way to skip datablock transfering from the server to the client on connection, like, if your game include tousand of them, it seems to be a bit silly to transfer them at every connection if you can have local copies on the client.
-Is there a way to skip on using datablocks, yet not need to transfer the object parameters to the client, having the "primordial" version of the object cached on the client and then only sending to the client what is different from this primordial template.
-If you set a transform in the datablock, does that mean the object can never move?, that you can never set a transform on it? or that it's simply the "default" position.
-Is there a way to make a datablock in such a way that it set the default value for certain parameters but that they can still be changed by the server?
About the author
3D artist, programmer, game designer, jack of all trades, master of none.
Associate Chris Haigler
Jester Dance
A1. Typically, yes. Datablocks are meant to be, well, blocks of static data that multiple objects of the same type reference. Changing a field in a datablock would result in changes to any object that referenced it. If you need to do things like change an object's model, you'll need to do that on a per-object basis.
As an example, let's say you had added a field to the PlayerData datablock called 'isHidden'. If it's set to true, any Player object would, on creation, be invisible. Now let's say that you wanted a Player object to reappear. You wouldn't set the 'isHidden' field of the PlayerData datablock to false, instead, you'd write a showPlayer() method in the Player class and call it when necessary.
Q2. Are changes to datablocks transmitted to clients?
A2. No, not by default. Datablocks are downloaded by a client during 'Phase 1' of the mission download sequence. During 'Phase 1', a server transmits all of the datablocks used in a level to the client. Any changes a client may have made to a datablock is overridden.
Q3. Can you skip or override datablock transmission?
A3. Yes. This resource: http://www.garagegames.com/community/blogs/view/15427 will do just that. Note that this is an old resource and may not work with T3D.