Torque/Networking/Ghosting/Examples

From TDN

Contents

Examples of Managing Ghost Objects


In Script

You want to pass an object ID from the server to a client

An example of this might be telling a particular client that some object is of special interest to them.


on the server:

function foo(%targetClient, %serverObject)
{
   %objIndex = %targetClient.getGhostID(%serverObject);
   commandToClient(%targetClient, 'bar', %objIndex);
}


on the client:

function ClientCmdBar(%objIndex)
{
   %clientObject = $gameConnection.resolveGhostID(%objIndex);
   %clientObject.DoSomething();
}


In the Engine