Problem implementing smooth AIPlayer turning.
by Endasil · in Torque Game Engine · 04/28/2006 (9:10 am) · 1 replies
I am trying to get enemies in my game to turn smooter, instead of flipping 180 degrees when i am behind it, i want it to turn towards me.
I tried to use the resource at this place: http://www.garagegames.com/index.php?sec=mg&mod=resource&page=view&qid=5268
but the result is that my enemies just disapear (there coordinates become 1.#QNA...) when i do a setMoveDestination().
What i do is in
bool AIPlayer::getAIMove(Move *movePtr)
{
...
F32 xDiff = mAimLocation.x - location.x;
F32 yDiff = mAimLocation.y - location.y;
...
}
I replace those two rows with
Point3F vDiff = mAimLocation - location;
vDiff.normalize();
mOrientation.normalize();
mOrientation.interpolate(mOrientation,vDiff,0.2);
F32 xDiff = mOrientation.x;
F32 yDiff = mOrientation.y;
and this causes the bots to disapear. Suggestions on ways of solving this?
I tried to use the resource at this place: http://www.garagegames.com/index.php?sec=mg&mod=resource&page=view&qid=5268
but the result is that my enemies just disapear (there coordinates become 1.#QNA...) when i do a setMoveDestination().
What i do is in
bool AIPlayer::getAIMove(Move *movePtr)
{
...
F32 xDiff = mAimLocation.x - location.x;
F32 yDiff = mAimLocation.y - location.y;
...
}
I replace those two rows with
Point3F vDiff = mAimLocation - location;
vDiff.normalize();
mOrientation.normalize();
mOrientation.interpolate(mOrientation,vDiff,0.2);
F32 xDiff = mOrientation.x;
F32 yDiff = mOrientation.y;
and this causes the bots to disapear. Suggestions on ways of solving this?
About the author
Associate Orion Elenzil
Real Life Plus
eg, a regular 3-component direction vector, not a quaternion or a set of euler angles or something ?
if mOrientation is not the forward vector, then definitely start there.
if it is the forward vector, then hmm..
it basically looks good to me.
i'd recommend examining the values you're getting in mOrientation after the interpolate.