Read/WritePacketData vs. PackUpdate question.
by Kent Butler · in Torque Game Engine · 01/15/2008 (2:07 pm) · 2 replies
If I understand things correctly, the Read/Write Packet data is always sent and the Pack/UnpackUpdate is controlled by the update masks. So the packetData functions are for active state information (like current engine RPM) and the update functions are for big 'ole dumps of information that rarely changes(all the engine parameters).
I guess question 1: is that right?
Question 2: Assuming this is correct, do you need to include the fields that you send with the read/write packet data functions in the pack/unpack update functions? Or is that redundant?
edit:typos
I guess question 1: is that right?
Question 2: Assuming this is correct, do you need to include the fields that you send with the read/write packet data functions in the pack/unpack update functions? Or is that redundant?
edit:typos
Torque Owner Stefan Lundmark
pack/unpackUpdate ()
* Gets called each tick, for all objects that are within scope.
* Has masks so you can decide what to send each update.
read/writePacketData ()
* Gets called each time the simulation differs on client/server. This is done in GameConnection.cpp.
* Does not have any masks.
* Only gets called for the controlling client.
Edit: I didn't answer your question, hehe. You use packUpdate to pass information that is critical for all clients to be able to keep their simulation current. You want to use writePacketData () for information that might be critical to the client which is controlling that object, or for information that you don't want other clients to know about.
Usually you can get away with dumping larger vectors and stuff into writePacketData () because it doesn't get written as often (shouldn't, but it's not always true depending on your network and game) and the fact that it only gets written to the controlling client. :)
Good night.