How to make AIPlayer do turn animation?
by Sibsan Suksuchano · in Torque 3D Professional · 09/14/2010 (2:59 pm) · 3 replies
T3D Beta 2
I've try to make Player to do turn animation by use "delta.rotVec.z" to check that my player is turning or not ,everthing work fine but when I add AIPlayer and set them to run follow path they don't do turn animation.
Anybody have a clue?
some info while player play turning animation they still moving not stop and turn.
If I change AIPlayer to AIClient will it fix this problem?
I've try to make Player to do turn animation by use "delta.rotVec.z" to check that my player is turning or not ,everthing work fine but when I add AIPlayer and set them to run follow path they don't do turn animation.
Anybody have a clue?
some info while player play turning animation they still moving not stop and turn.
If I change AIPlayer to AIClient will it fix this problem?
About the author
Abstract Wings Co., Ltd. (ABWING) is a gaming technology developer especially Arcade Games, we do Hardware Software and also Arts for good games.
Recent Threads
#2
in player.cpp find:
then still in player.cpp, find this block of code:
now in player.h, find
rebuild your project,
having done that, open gideon.cs, or whatever your player, or aiPlayer is, and add this:
now you will need a turn animation,
thats for you to do,
to test it,
copy the crouch animation
and rename it to "player_turnanim.dsq",
and place it in the proper folder,
now when you or whoever else has the turn animation,
they/ you will crouch when turning.
09/14/2010 (10:02 pm)
Sibsan,in player.cpp find:
{ "side", { -1.0f, 0.0f, 0.0f } }, // SideLeftAnim,and below it add this:{ "turn", { -1.0f, 0.0f, 0.0f } }, // TurnAnimthen still in player.cpp, find this block of code:
for (U32 i = 1; i < PlayerData::NumMoveActionAnims; i++)
{
PlayerData::ActionAnimation &anim = mDataBlock->actionList[i];
if (anim.sequence != -1 && anim.speed)
{
// We bias towards picking the forward/backward anims over
// the side to prevent oscillation between anims. This seems
// to work ok but the real fix is to have 8 way directional
// animations.
VectorF biasedDir = anim.dir * VectorF(0.5f,1.0f,0.5f);
F32 d = mDot(vel, biasedDir);
if (d > curMax)
{
curMax = d;
action = i;
forward = true;
}
else
{
// Special case, re-use slide left animation to slide right
if (i == PlayerData::SideLeftAnim && -d > curMax)
{
curMax = -d;
action = i;
forward = false;
}
}
}and replace it with this://///////////////////// DS turn anim begin //////////////////////////////////////
if ( mFabs( vel.x + vel.y ) < 0.25 )
{
// And we're turning
if ( delta.rotVec.z != 0 )
{
// Let's sidestep to look like we're turning
action = PlayerData::TurnAnim;
forward = true;
// If we're turning right animate the other way
if ( delta.rotVec.z < 0 )
forward = false;
}
}
else // Continue on as normal if we're moving
{
for (U32 i = 1; i < PlayerData::NumMoveActionAnims; i++)
{
PlayerData::ActionAnimation &anim = mDataBlock->actionList[i];
if (anim.sequence != -1 && anim.speed)
{
F32 d = mDot(vel, anim.dir);
if (d > curMax)
{
curMax = d;
action = i;
forward = true;
}
else
{
// Special case, re-use slide left animation to slide right
if (i == PlayerData::SideLeftAnim && -d > curMax )
{
curMax = -d;
action = i;
forward = false;
}
}
}
}
/////////////////////// DS turn anim end //////////////////////////////////////now in player.h, find
SideLeftAnim,and below it, add:
TurnAnim, // TurnAnim
rebuild your project,
having done that, open gideon.cs, or whatever your player, or aiPlayer is, and add this:
sequence45 = "./player_turnanim.dsq turn";under this:
sequence44 = "./player_swimsiderg.dsq swim_right";
now you will need a turn animation,
thats for you to do,
to test it,
copy the crouch animation
and rename it to "player_turnanim.dsq",
and place it in the proper folder,
now when you or whoever else has the turn animation,
they/ you will crouch when turning.
#3
After test and test I found the problem.In normaly player and AI animation go fine until I have applyImpulse to AI then the delta.rotVec in client side go to 0 only the serverside update.
Any idea?
09/15/2010 (4:11 am)
@deepscratch infact I've used your code with comment out mfabs vel.x and vel.y to make player turn even he run.After test and test I found the problem.In normaly player and AI animation go fine until I have applyImpulse to AI then the delta.rotVec in client side go to 0 only the serverside update.
Any idea?
Torque Owner Ivan Mandzhukov
Liman3D
So a possible issue is when you set a rotation,then this value is replaced with a new one.
Well,you can change this situation in AIplayer::getAIMove() and provide your own logic there, thus you can directly play your animation with setActionThread().