Game Development Community

Obj.getGhostID no longer applicable?

by Justin Mosiman · in Torque Game Engine Advanced · 07/31/2007 (3:50 pm) · 3 replies

Whenever I try to use the %obj.getGhostID() function in TorqueScript, I always get a return id of -1. I tried this in stock TGEA 1.0.1 and it produced the same results. So my question is if this is supposed to be working, and if not, is there an alternative to %obj.getGhostID()?

#1
07/31/2007 (4:23 pm)
With TGE the ghostID for a given object on the server will depend upon which client you're interested in E.G the ghostID for %obj on clientA could be different to the ghostID on clientB.

Thus to get the ghost id you need to call it on a specific/relevant GameConnection

%ghostID = %client.getGhostID(%obj.getId());
echo(%ghostID);

I've not checked whether this is still the case with TGEA, although I'd assume it is.
#2
07/31/2007 (6:57 pm)
Edit: nevermind, that worked. Thanks
#3
08/09/2007 (5:18 pm)
I hate to post again, but I thought I had it working but it really wasn't and I'm just now getting to it again.

Here is the code that I have:
function serverCmdAddToSelection(%client, %objID)
{
   echo("objID" SPC %objID);
   echo("ghostID" SPC %client.getGhostID(%objID));
   %obj = %client.resolveObjectFromGhostIndex(%client.getGhostID(%objID));
   %client.selection.add(%obj);
}

That is in server/commands.cs, and it is being called like:
commandToServer('AddToSelection', %obj.getID());

The first objID echo worked fine, printing a result of 1652. When I echo the ghostID I still get a value of -1. This is the same case when one machine is a client/server and when another machine is just a client.

Am I calling everything correctly?