How to force newly created object to Ghost?
by Ed Zavada · in Torque Game Engine · 02/23/2008 (4:50 am) · 2 replies
I've been trying to add clothing dynamically in C++, but I've run into a problem getting newly created objects to Ghost quickly. Basically in my EquipClothing method, I create the clothing object instance from its datablock, then assign it to an array in the Player object and set a clothing mask. On the next network update, Player::packUpdate sees the clothing mask bit and sends down the ghost ids for all the clothing objects in the array. Unfortunately, they haven't been ghosted yet, so getGhostIndex() returns -1.
I've tried walking the connection list and calling checkPacketSend on all client connections after creating the object, but that doesn't seem to help.
My only solution so far has been to schedule a clothing update for a second later, but even that doesn't always work, and there are timing issues with coordination of animations because of it, so it's imperfect at best.
What I really would like is a way to just force the network code to ghost the object right after I've created it. Does anyone know a way to do this?
Alternatively, I might be able to work with some kind of hook into the ghosting process so I would know when the object was ghosted and tell the player do update then.
Any suggestions would be greatly appreciated!
I've tried walking the connection list and calling checkPacketSend on all client connections after creating the object, but that doesn't seem to help.
My only solution so far has been to schedule a clothing update for a second later, but even that doesn't always work, and there are timing issues with coordination of animations because of it, so it's imperfect at best.
What I really would like is a way to just force the network code to ghost the object right after I've created it. Does anyone know a way to do this?
Alternatively, I might be able to work with some kind of hook into the ghosting process so I would know when the object was ghosted and tell the player do update then.
Any suggestions would be greatly appreciated!
#2
02/24/2008 (8:10 am)
That seems to have done the trick. It still takes a few passes before the clothing array is updated on the client, but at least it's guaranteed to happen now. I can resynchronize the threads by swapping animations in script, so I think this will be good enough for now.
Torque 3D Owner Robert Blanchet Jr.
This doesn't solve your one problem though, with sending a ghost right away, but it does solve the issue where the ghost hasn't been created on that client yet, and will resend your 'clothing mask' until it is.