Unit movement question
by Christian · in RTS Starter Kit · 07/29/2007 (9:53 am) · 6 replies
Just a simple movement question. When using commands such as .setMoveDestination and .setMoveGoal for units their animations don't work correctly, they kind of float in a jerk motion to their destination, the animations work correctly on the right click move, just not when typing in the commands. Has anyone had this problem before?
#2
07/29/2007 (2:46 pm)
Ooh that did the trick Novack! The moving has to be done in script so I made a new function out of that one.function gogo(%noob, %x, %y, %z)
{
%center = VectorScale(%center, 1);
%obj = %noob;
%dest = %x SPC %y SPC %z;
%offset = VectorSub(%obj.getPosition(), %center);
%dest = VectorAdd(%dest, %offset);
%obj.clearAim();
%obj.resourceType = "";
%obj.TCLoc = "";
%obj.resourcePos = "";
%obj.status = "Idle";
%obj.curGoal = "";
%obj.setMoveGoal(%dest);
}gogo(%noob, 222, 333, 222);to move single bots from script.
#4
07/29/2007 (6:21 pm)
The other one relies on you selecting a unit in the game. Mine all have to be done through script without selecting units. I still don't understand why the animation doesn't work properly when using setMoveGoal or setMoveDestination, but for now this works.
#5
Apparently, beacuse of how setMoveDestination works, a clearAim() must be done. When we use the mouse, commandToServer('IssueMove', %x, %y, %z) send this %obj.clearAim(); just before %obj.setMoveGoal(%dest);
So, to use setMoveGoal from a script you just need to add %this.clearAim(); to the setMoveGoal function:
07/29/2007 (10:15 pm)
Mhh gotcha (I think).Apparently, beacuse of how setMoveDestination works, a clearAim() must be done. When we use the mouse, commandToServer('IssueMove', %x, %y, %z) send this %obj.clearAim(); just before %obj.setMoveGoal(%dest);
So, to use setMoveGoal from a script you just need to add %this.clearAim(); to the setMoveGoal function:
function Player::setMoveGoal(%this, %dest)
{
[b]%this.clearAim();[/b]
%this.curGoal = %dest;
// Kick off the movement.
%this.onReachDestination(%this.getPosition());
}So, using%noob.setMoveGoal("222 333 222");You dont need the patch-function :)
#6
07/30/2007 (6:44 am)
Thank you, that saves a lot of trouble for all the movement (that other function would be a pain with vectors & such).
Torque 3D Owner Novack
CyberianSoftware
Depending on what you want to do, you can use commandToServer('IssueMove', %x, %y, %z); instead.