AI Move to "@%pos@" ."); %this.setMoveDestination(%pos, %p"> Vectors in functions | Torque Game Engine | Forums | Community | GarageGames.com

Game Development Community

Vectors in functions

by ... · in Torque Game Engine · 08/29/2006 (11:28 am) · 1 replies

Hello everyone,

I want my AIplayer to move to a location
this is what ive done so far

function AIPlayer::moveToPos(%this,%pos)
{
   // Move to the given position x y z
   echo("-->AI Move to "@%pos@" .");
   %this.setMoveDestination(%pos, %pos);
}
this function seems not to get a %pos value


function serverCmdTestmoveTo(%client)
{
   %pos = %client.player.getTransform();
   echo("Move to "@%pos@" .");
   $Squad[1].pushTask("moveToPos(%pos)");
}

GlobalActionMap.bindCmd(keyboard, "n", "commandToServer('TestmoveTo');", "");

any help is welcome.

Thanks ,

Robin.

#1
08/29/2006 (6:12 pm)
I haven't dug into AI so I can't comment on that but you seem to have a fundamental mismatch between your call and your subroutine.

You call the subroutine passing only one value: moveToPos(%pos)
But the subroutine is expecting two values: moveToPos(%this,%pos)

Your subroutine call should match the arguments of the subroutine being called.

If you're going to use "this" in the subroutine you need to pass it in along with "pos" or if you don't need it drop it off and only pass pos. I suspect that what you want to do is pass in the "this" being moved along with the position you want it to move to. If you supply only the position the subroutine as no idea of what you want moved or any way to access it.

HTH,

=Tod