NPC movement
by Scott Doerrfeld · in Torque Game Engine · 04/03/2007 (10:00 am) · 4 replies
I'm using the MoveTo function for my NPC characters, so when you click on one, it moves toward you. But what I want is that when the NPC gets up to a certain distance from my player, they should stop. Does anyone have any ideas on how I could accomplish this?
About the author
#2
Once I got the vector math right, the motion turned out just the way I wanted. However, I stumbled upon a different problem. My AIPlayer moves using the setMoveDestination function to start moving. I want the AIPlayer to start an animation upon reaching the point he is supposed to stop at. For some reason, it seems the onReachDestination function isn't being called, which is where I would start the animation. I know it should be getting called because inside the getAIMove function where there is a check to see if the AIPlayer has reached the desired location, there is a throwback to onReachDestination. But I used an echo statement at the beginning of onReachDestination to print something to the console and it isn't printing which leads me to believe it isn't being called. I'm so confused.
Any ideas?
04/04/2007 (8:27 am)
Thanks Orion!Once I got the vector math right, the motion turned out just the way I wanted. However, I stumbled upon a different problem. My AIPlayer moves using the setMoveDestination function to start moving. I want the AIPlayer to start an animation upon reaching the point he is supposed to stop at. For some reason, it seems the onReachDestination function isn't being called, which is where I would start the animation. I know it should be getting called because inside the getAIMove function where there is a check to see if the AIPlayer has reached the desired location, there is a throwback to onReachDestination. But I used an echo statement at the beginning of onReachDestination to print something to the console and it isn't printing which leads me to believe it isn't being called. I'm so confused.
Any ideas?
#3
hmm, sounds like a bug in the AIPlayer movement stuff.
no ideas off the top other than taking a look at where onReachDestination is called from and seeing why it's not being called.. ;)
04/04/2007 (9:53 am)
Heya -hmm, sounds like a bug in the AIPlayer movement stuff.
no ideas off the top other than taking a look at where onReachDestination is called from and seeing why it's not being called.. ;)
#4
04/10/2007 (8:23 am)
I read this somewhere in the forum, you should check for %player.setMoveTolerance(10); when creating AIPlayer
Associate Orion Elenzil
Real Life Plus
in vector math:
to convert the above to torquescript,
look up the vector script functions such as vectorAdd(), vectorNormalize() etc.