Objects Ghosting only to certain clients
by Dave Young · in Torque Game Engine · 07/12/2006 (10:05 am) · 6 replies
I am thinking of the best way to go about creating ingame objects which would only appear to certain clients.
I know how to create client-side only objects, and there is a isHidden flag for objects as well, but that disables them for all clients.
Some example uses are for things like Cloaking, where maybe your team members can see you but others can't. Or ingame spawner objects that can only be seen by admin clients.
I've looked around for a resource, thought I would check in here incase someone has some thoughts!
I know how to create client-side only objects, and there is a isHidden flag for objects as well, but that disables them for all clients.
Some example uses are for things like Cloaking, where maybe your team members can see you but others can't. Or ingame spawner objects that can only be seen by admin clients.
I've looked around for a resource, thought I would check in here incase someone has some thoughts!
#2
07/12/2006 (10:42 am)
Great idea, thanks!
#3
So changing it here still changes it for everyone, not specific clients.
Maybe it's the unpack update that I need to change...
Am I correct?
07/12/2006 (1:20 pm)
This seems like a good approach, and as I was coding the packUpdate routine, I realized that this (packUpdate) only gets done once, on the server, and then ghosted to the clients.So changing it here still changes it for everyone, not specific clients.
Maybe it's the unpack update that I need to change...
Am I correct?
#4
Could you modify the scoping query for clients in 'SceneGraph::scopeScene'?
07/12/2006 (2:05 pm)
WARNING: UNTESTED IDEACould you modify the scoping query for clients in 'SceneGraph::scopeScene'?
#5
actually, packUpdate() is called once per object being ghosted per client being ghosted to,
not once per object being ghosted.
that is, if you're ghosting an object out to seven clients, its packUpdate() is called seven times, with a different client each time.
take for example the case where players are hidden from people on different teams.
in that case, the general player object could implement "isHiddenForThisClient()" like this:
.. i'm not sure if GameConnection::getPlayerObject() is part of stock TGE or not, it may be something we added.
i'm pretty sure this technique should work.
i'm using it currently in a chat context to block certain lines of conversation from some players and not from others.
07/12/2006 (3:24 pm)
Hiya -actually, packUpdate() is called once per object being ghosted per client being ghosted to,
not once per object being ghosted.
that is, if you're ghosting an object out to seven clients, its packUpdate() is called seven times, with a different client each time.
take for example the case where players are hidden from people on different teams.
in that case, the general player object could implement "isHiddenForThisClient()" like this:
bool Player::isHiddenForThisClient(NetConnection* nc)
{
GameConnection* gc = dynamic_cast<GameConnection*>(nc);
if (gc == NULL)
// error!
Player* otherPlayer = gc->getPlayerObject();
if (otherPlayer == NULL)
// error!
bool sameTeam = (otherPlayer->getTeam() == this->getTeam());
return !sameTeam;
}.. i'm not sure if GameConnection::getPlayerObject() is part of stock TGE or not, it may be something we added.
i'm pretty sure this technique should work.
i'm using it currently in a chat context to block certain lines of conversation from some players and not from others.
#6
07/12/2006 (3:40 pm)
Thanks for the education! I love to learn stuff like this :)
Associate Orion Elenzil
Real Life Plus
eg
instead of this:
do something like this:
edit: of course, client-side cheats are still possible with something as simple as an isHidden() flag, but maybe that's something you could deal with when it becomes a problem for your app.