Game Development Community

Classes help

by jerryg7rk3w · in General Discussion · 10/21/2010 (4:14 am) · 2 replies

Hello this is a simple question but I'm going to ask it anyways, because first I'm a noob and second i don't fully understand if someone would use a class vs a Datablock over a network.

Well i understand that Datablocks are static and only sends info from a server to a client once, so the network wont get boggled down by sending information repeatedly that doesn't change. But are classes static too? I cant find any info on if they are or if their dynamic?

So my best guess is they are dynamic and if used instead of Datablocks they would eventually boggle down the network so that's why there are Datablocks because they act like classes only with static info being sent, am i right?

#1
10/21/2010 (8:15 am)
Let's get this straight first: 'classes' are different to 'objects'. Every object belongs to a class - even datablocks belong to the class they represent. PlayerData and Player are both 'classes'. The datablock PlayerBody and the Player you control in-game are both objects.

Datablocks are special kinds of objects that, like you say, are static - they don't ever change once they've been created, so you only have to send them down the network once.

'Regular' objects, like those of the Player or Vehicle classes, have properties that need to change, like their current position or damage level. But they also have properties that don't need to change, like their shape file or maximum damage. So it's possible to just send all that data with every Player and Vehicle object that get created, but it's a bit of a waste. So in Torque we separate out the static data into a datablock object, and give each object a reference to a datablock which they can look up their static data in. This means the data's stored in one location, instead of being duplicated everywhere.
#2
10/21/2010 (3:50 pm)
What if i develop a game that has classes and then decide that i wanted to set that game up to be played on a network would i have to go back through the code and pick out all the static stuff and create Datablocks for all that info,and would i have to replace all the classes with Datablocks instead?

Sorry about this I'm still kinda lost on it but think i understand for the most part.