Array ghosted?
by gamer · in Torque Game Engine · 01/08/2007 (10:47 am) · 9 replies
The Array class inherits from SimObject, does this mean it's already ghosted? It doesn't have any pack or unPack function though..
thanks!
thanks!
About the author
#3
thanks!
01/08/2007 (11:01 am)
I currently need some ghosted object that acts as a generic data holder, it must either hold a list of string data or has a name to value map functionality. is there anything I can use?thanks!
#5
01/08/2007 (12:21 pm)
Yes networkable
#6
01/08/2007 (1:34 pm)
Yes networkable
#7
10/24/2009 (10:49 pm)
Would making your own console object that is scoped to scripting that inherits from Net Object would make this class ghost able? and fulfill the purpose?
#8
Make sure to make the class a networked object
and in the constructor, simply mark the object as ScopeAlways so it will be pushed out to all clients:
Then just implement the packUpdate and unpackUpdate functions. If the array values don't really change a lot, you don't need to make the whole updating very smart and could just push all the values on each update. If the values do change quite a bit, send only deltas.
However, while all this isn't that difficult, the fact you want such a class in the first place hints at a problem. There are usually better ways to implement networked logic than doing it like this.
Maybe you would like to explain a little what you are planning to do here.
10/25/2009 (8:00 am)
In principle this is pretty simple. You could implement your custom networked array class, like e.g. NetworkedArrayObject that inherits from ArrayObject.Make sure to make the class a networked object
IMPLEMENT_CO_NETOBJECT_V1( NetworkedArrayObject );
and in the constructor, simply mark the object as ScopeAlways so it will be pushed out to all clients:
mNetFlags.set( Ghostable | ScopeAlways );
Then just implement the packUpdate and unpackUpdate functions. If the array values don't really change a lot, you don't need to make the whole updating very smart and could just push all the values on each update. If the values do change quite a bit, send only deltas.
However, while all this isn't that difficult, the fact you want such a class in the first place hints at a problem. There are usually better ways to implement networked logic than doing it like this.
Maybe you would like to explain a little what you are planning to do here.
#9
Ah, of course, I overlooked one thing there. You can't derive from ArrayObject since it's only a SimObject. You need to derive directly or indirectly from NetObject.
10/25/2009 (8:05 am)
Ah, of course, I overlooked one thing there. You can't derive from ArrayObject since it's only a SimObject. You need to derive directly or indirectly from NetObject.
Torque Owner Stefan Lundmark
Neither does having unpack() and pack() functions.