Hello,
I’m making a character going where the player click. I’m using navmesh to make the move and legacy animation system for the animation (duh)
Two of my animation don’t work.
I have 4 animationClip (idle, moveForward, moveToTheLeft, moveToTheRight)
Each animation is played when necessary through code and state and seems to works (My debug message told me that all is working).
The problem is the moveToTheLeft and moveToTheRight doesn’t work even if they are called without error. Each time they should be playing, the model stop being animated until it change state.
But when I’m putting a model with only the moveToTheLeft (and right) in an animation component it’s working well.
Here is the 2 main functions responsible of the animations.
/*
* setAnimation took the animation clip set in the editor to put them
* in the animation component with a generic name, it allows more flexibility.
*
*/
void setAnimations()
{
// If there is a clip in the editor, add it to the animation component
if (IdleClip != null)
animations.AddClip(IdleClip, "idle");
if (MoveClip != null)
animations.AddClip(MoveClip, "move");
if (MoveRightClip != null)
animations.AddClip(MoveRightClip, "moveRight");
if (MoveLeftClip != null)
animations.AddClip(MoveLeftClip, "moveLeft");
}
/*
* setState is called by thge movement function each time it need to.
*
*/
public void setState(EState newState)
{
bool changeStateSuccess = true;
// The switch go through all the possible case and play the corresponding animation
switch (newState)
{
case EState.IDLE:
// We are trying to play the animation set previously
if (!animations.Play("idle", PlayMode.StopAll))
Debug.LogError("Animation idle not playing");
break;
case EState.MOVING:
if (!animations.Play("move", PlayMode.StopAll))
Debug.LogError("Animation move not playing try playing : walk_v05");
break;
case EState.MOVING_RIGHT:
print ("AnimManager move rioght is playing");
// here, the animation is playing I never received the Error log.
if (!animations.Play("moveRight", PlayMode.StopAll))
Debug.LogError("Animation moveRight not playing, try playing : walkRight_v04");
break;
case EState.MOVING_LEFT:
print ("AnimManager move left is playing");
if (!animations.Play("moveLeft", PlayMode.StopAll))
Debug.LogError("Animation moveLeft not playing, try playing : walkLeft_v04");
break;
default:
Debug.LogError("There is no animation corresponding.");
changeStateSuccess = false;
break;
}
// If there is no animation available we don't change the state.
if (changeStateSuccess)
currentState = newState;
}
And here I am without any solution. Although the legacy system isn’t maintained anymore, does anyone know a solution or can give me an hint?
Thanks a lot people and have a good day.