Object ID's on client and server
by Johan Janssen · in Torque Game Engine · 02/04/2008 (1:26 am) · 4 replies
I'm rather new to Torque, and I'm just beginning to figure out how the script/engine works.
As I posted in a previous post I'm working on a scripted animation system. But I'm running into a wall regarding the objects that are referenced in the engine.
What I can not wrap my head around is the following:
The server should flag that a certain object's animation is script controlled and tell all clients about this.
The ID's and memory addresses of what is changed and rendered are different.
%obj.client.getControlObject()'s ID on the server is 1541
%client.getControlObject() on the client is also 1541, the memory address (C++) points to exactly the same object.
HOWEVER, the rendered/animated object is 1542.
1541 and 1542 share the same datablock, so they do seem to be the same game object.
I don't understand this. Should object ID's not be the same on the client and server and should the client not have a copy in memory of the object?
As I posted in a previous post I'm working on a scripted animation system. But I'm running into a wall regarding the objects that are referenced in the engine.
What I can not wrap my head around is the following:
The server should flag that a certain object's animation is script controlled and tell all clients about this.
// SERVER
function SomeRandomCallback(%obj)
{
commandToClient(%obj.client, 'enableScriptedBoneRotation', %obj.client);
}
//CLIENT
function clientCmdFreeHeadRotation(%player)
{
%player.getControlObject().enableScriptedBoneRotation("Bip01 Neck");
}The ID's and memory addresses of what is changed and rendered are different.
%obj.client.getControlObject()'s ID on the server is 1541
%client.getControlObject() on the client is also 1541, the memory address (C++) points to exactly the same object.
HOWEVER, the rendered/animated object is 1542.
1541 and 1542 share the same datablock, so they do seem to be the same game object.
I don't understand this. Should object ID's not be the same on the client and server and should the client not have a copy in memory of the object?
#2
I tried %obj.client.player, which is 1541, which is a server object.
The clientCmd then also receives 1541.
But the object I need is 1542, which is a client object.
02/04/2008 (2:32 am)
Hi Gabriel,I tried %obj.client.player, which is 1541, which is a server object.
The clientCmd then also receives 1541.
But the object I need is 1542, which is a client object.
#3
1. Convert the server object ID to that particular client's ghost index.
2. Send the ghost index to the client.
3. On the client convert the ghost index to object ID (local).
Something like
On the server:
And on the client:
That is the basic process, although I'm not sure if I have given the exact functions.
Gabriel
02/04/2008 (2:58 am)
The object IDs are different on the server then on the client. To convert a server object ID to a client one:1. Convert the server object ID to that particular client's ghost index.
2. Send the ghost index to the client.
3. On the client convert the ghost index to object ID (local).
Something like
On the server:
%ghostIndex=%client.getGhostID(%ID)Send %ghostIndex to the same client as specified in %client (the ghost ID will be specific to that client)
And on the client:
%localID=serverconnection.resolveGhostID(%ghostIndex)
That is the basic process, although I'm not sure if I have given the exact functions.
Gabriel
Torque Owner Gabriel Notman
Gabriel