SetAimObject/doClientAttackAnimation difficulties
by Swarthmore College (#0007) · in RTS Starter Kit · 06/19/2007 (11:18 am) · 3 replies
Hey all,
I have a problem with setAimObject and doClientAttackAnimation. Basically, when I tell an object to set its aim object:
%currUnit.setAimObject(%goal);
%currUnit has an ID that's something 1585 (it doesn't really matter). But I want to know after the first 'firing' animation has been played, so I have another little check in playAttackAnimation:
echo("this: " @ %this);
The problem here is that '%this' in playAttackAnimation is a different ID number than %currUnit was when setAimObject was called. I traced this back to doClientAttackAnimation, which is called from processTick in RTSUnit. Basically, the ID number goes into code from the script, and when it comes out of code it's a different ID number. If I'm in world editor view, I can't see the second ID number anywhere in the world, only the first one, though I can get its position by echoing it.
I don't know if anyone will ever see this post, but if you do, and you know anything about this, any help would be greatly appreciated.
Thanks.
I have a problem with setAimObject and doClientAttackAnimation. Basically, when I tell an object to set its aim object:
%currUnit.setAimObject(%goal);
%currUnit has an ID that's something 1585 (it doesn't really matter). But I want to know after the first 'firing' animation has been played, so I have another little check in playAttackAnimation:
echo("this: " @ %this);
The problem here is that '%this' in playAttackAnimation is a different ID number than %currUnit was when setAimObject was called. I traced this back to doClientAttackAnimation, which is called from processTick in RTSUnit. Basically, the ID number goes into code from the script, and when it comes out of code it's a different ID number. If I'm in world editor view, I can't see the second ID number anywhere in the world, only the first one, though I can get its position by echoing it.
I don't know if anyone will ever see this post, but if you do, and you know anything about this, any help would be greatly appreciated.
Thanks.
About the author
#2
With your suggestion, I was able to verify that it was indeed a confusion of client and server IDs. It turns out, that in processTick in RTSUnit.cc, there is the code:
And I was trying to do stuff in doClientAttackAnimation instead of onAttack, which is where I should have been doing it if I wanted server IDs.
Thanks again.
06/22/2007 (12:59 pm)
Thanks so much for your reply!With your suggestion, I was able to verify that it was indeed a confusion of client and server IDs. It turns out, that in processTick in RTSUnit.cc, there is the code:
Quote: if(isServerObject())
{
// Do a proper method callback...
Con::executef(mDataBlock, 3, "onAttack", scriptThis(), mAimObject->getIdString());
}
else
{
// Call a goofy global function to do the client side animation.
Con::executef(3, "doClientAttackAnimation", scriptThis(), mAimObject->getIdString());
}
And I was trying to do stuff in doClientAttackAnimation instead of onAttack, which is where I should have been doing it if I wanted server IDs.
Thanks again.
#3
The selection code works with GhostID's on the client side and transmits them (per selection step) to the server, which then converts them to the appropriate ServerID's via scripted wrappers to the methods Gavin describes above.
06/22/2007 (1:14 pm)
You should also take a look at the process flow for when you select units on the client, and then issue orders to that selection group.The selection code works with GhostID's on the client side and transmits them (per selection step) to the server, which then converts them to the appropriate ServerID's via scripted wrappers to the methods Gavin describes above.
Torque Owner Gavin Bunney
When an object is on the server, it is assigned an id. The object is then 'ghosted' to the client (kinda like a shallow copy), which makes its own id for that object. So therefore, the server's id of an object will be different to the clients view.
So the trick is to know where you want to make the changes after the first firing animation. The functions to have a look at (in netConnection.cc) are: resolveGhost, resolveObjectFromGhostIndex, and getGhostIndex - They are responsible for converting to or from a server/client id.
If you do a search on the client/server id difference you should find plenty of information about it.