- Home /
My animation is not playing
"WalkAnimation" is not playing but "Animation played" messeage is coming. Please help with my problem. Thanks :)
public class BotAI : MonoBehaviour
{
NavMeshAgent navigation;
Animator anim;
Transform target;
void Start()
{
navigation = GetComponent<NavMeshAgent>();
anim = GetComponent<Animator>();
}
void Update()
{
navigation.destination = target.position;
chspeed = (transform.position - lastPosition).magnitude / Time.deltaTime;
lastPosition = transform.position;
if (chspeed >= 1.485f)
{
anim.Play("WalkAnimation");
Debug.Log("Animation played")
}
}
}
Answer by MickyX · May 03 at 03:05 PM
Assuming you have it named correctly try
anim.Play("Base Layer.WalkAnimation")
Personally I think you should look at using Parameters
In your animator controller create a bool parameter called "Walking" Then create a transition between your idle and walking and set the condition to Walking true and a transition back from your walking to idle with the condition Walking false.
Then set that bool
anim.SetBool("Walking",true);
Answer by whynotgamesofficial · May 14 at 12:18 PM
@MickyX still, not working
the animation plays once and dont plays again
@whynotgamesofficial Make sure Loop Time is checked in your animation.
Click your animation in your assets
Click Edit Animation
Tick the checkbox for loop time
Try again