Game Development Community

Time to ghost

by Ian Omroth Hardingham · in Torque Game Engine · 08/05/2004 (5:08 am) · 7 replies

Hey everyone.

When I create a new player on the server, it takes some time (a second or so) for it to ghost onto each client. However, there are some settings (target object etc) which I wish to be passed on to the client ghosts. Is the best thing to do to schedule the function calls for 1.5 seconds time, or is there a better way of doing this?

Any help much appreciated,

Ian

#1
08/05/2004 (7:39 am)
I don't know too much about the networking code yet. But I'd guess that you could add code in the the ghosted object's ::onAdd event. This code would then to a CommandToServer call that would tell the server that the ghost has been created and that it's ok to send the extra information needed. That'll avoid timing problems.

Hope that helps, I'm sure I got some of the specifics wrong, but the general idea should work well.
#2
08/05/2004 (8:51 am)
Brian has the right spirit but the specifics aren't quite right. You want to modify the packUpdate and unpackUpdate methods to write out your data. That way it will go along with the ghost updates. Using commandToClient/Server might work but it won't quite be in synch with the other updates which might lead to some nasty bugs. Check the C++ reference manual for NetObject and you should learn what you need to know.
#3
08/06/2004 (2:54 am)
Thanks for the help guys.

Here's the exact problem. I've got one player in the world. When I add another (at an arbitrary time) I want to set the old player's "target object" to be the new one. That's fine for the server, but when, in pank/unpackUpdate, the server old player informs the server new player to search for the ghost of the new target, it can't be found, as it hasn't been ghosted yet.

I can get around this problem with schedules, just wondering if there was a neater way.

Ian
#4
08/11/2004 (8:32 pm)
Sure is!

Check the ghost ID. If it's -1, return a non-zero bitmask from the packData method. It will keep retrying till the ghost resolves.
#5
08/12/2004 (1:53 am)
Wow, *that's* the use of the return bitmask. Thanks Ben, that's very useful info.

Ian
#6
08/12/2004 (6:50 am)
I now have a similar but different problem involving datablocks.

In one of my datablocks, I reference another:

datablock A(Moon)
{
...
};

datablock B(Blah)
{
...
dataA = Moon;
...
};

At the moment, this works fine just as long as A is executed before B, and everything's cool. However, I have a questions:

if A is executed before B, it's obviously already in the scope when B is executed. However, is the same true over the network? ie, if A is executed before B on the server, is it guaranteed A will be ghosted before B?

Any help, much appreciated.

Ian
#7
08/12/2004 (8:16 am)
Datablocks aren't ghosted. Their IDs are guaranteed to be the same across all servers and clients and stuff. One of the useful things about datablocks. ;)