- Home /
Animator not playing Animator Controller
The error I get is ...
Animator is not playing an AnimatorController UnityEngine.Animator:SetBool(String, Boolean) PlayerMovement:FixedUpdate() (at Assets/Scripts/PlayerMovement.cs:31)
Blockquote
I think the error pops up every time the SetBool is called in the script. Not very sure though as this is my first tutorial. The John Lemon game character is supposed to be able to move around in its walk animation and also when not moving it is supposed to be in its idle animation. However, the character is frozen due to the error.
Blockquote
I'm working on the beginner John Lemon's Haunted Jaunt. I'm using Unity 2019.1.13 and the tutorial recommends versions from 2018.3 and 2019.1. I'm currently on the Player Character: Part 2 section of the tutorial.
Blockquote
This is the script I've written:
Blockquote
using System.Collections; using System.Collections.Generic; using UnityEngine;
public class PlayerMovement : MonoBehaviour { public float turnSpeed = 20f;
Animator m_Animator;
Rigidbody m_Rigidbody;
Vector3 m_Movement;
Quaternion m_Rotation = Quaternion.identity;
void Start()
{
m_Animator = GetComponent<Animator>();
m_Rigidbody = GetComponent<Rigidbody>();
}
void FixedUpdate()
{
float horizontal = Input.GetAxis("Horizontal");
float vertical = Input.GetAxis("Vertical");
m_Movement.Set(horizontal, 0f, vertical);
m_Movement.Normalize();
bool hasHorizontalInput = !Mathf.Approximately(horizontal, 0f);
bool hasVerticalInput = !Mathf.Approximately(vertical, 0f);
bool isWalking = hasHorizontalInput || hasVerticalInput;
m_Animator.SetBool("IsWalking", isWalking);
Vector3 desiredForward = Vector3.RotateTowards(transform.forward, m_Movement, turnSpeed * Time.deltaTime, 0f);
m_Rotation = Quaternion.LookRotation(desiredForward);
}
void OnAnimatorMove()
{
m_Rigidbody.MovePosition(m_Rigidbody.position + m_Movement * m_Animator.deltaPosition.magnitude);
m_Rigidbody.MoveRotation(m_Rotation);
}
}
Is there a controller supplied to your Animator component? It's not being assigned in that script, so it'd need to be assigned in the inspector or somewhere else.
set bool gives a error when that bool variable dont exist on animator, as TreyH wrote, that happens when arent a animator controller present OR when you wrote bad the variable on the animator, are you sure that the name of the bool on the animator is IsWalking
(caps sensitive)?