Game Development Community

Questions regarding Datablocks and thier use

by \"Robert Jaramillo\" · in Torque Game Engine · 02/17/2010 (7:36 pm) · 1 replies

Hello, everyone


I am a little confused on the general use of data blocks and? My main point of confusion comes from when is the right time to use them? To my understanding they share the same attributes with multiple objects, which makes them similar to a singleton in C++. However I am also getting the impression that they are used to extend classes? which doesn't make sense to me by any means. I would really appreciate anyone who could help clear this up for me a whole thanks you guys and have a nice day. Look forward to hearing from you soon.


#1
02/17/2010 (9:30 pm)
Quote:My main point of confusion comes from when is the right time to use them? To my understanding they share the same attributes with multiple objects
Basically, datablocks are blueprints. When you create an object in Torque, say a WheeledVehicle, you have to specify a WheeledVehicleData datablock to act as the 'blueprint' for that vehicle. You can create as mkany unique WheeledVehicle objects as you like which all use the same WheeledVehicleData object as their blueprint.
'When to use them' is basically always, since most objects require a datablock, or they will not be created. This makes sense, since datablocks specify things like which shape file to use - can't create a WheeledVehicle with no body.

Quote:However I am also getting the impression that they are used to extend classes?
See this thread for a little more info on that. Basically, datablock names are used kind of like 'namespaces' for objects. It's a weird system, but I find it makes sense and works well once you get your head around it.