How can I solve this error?
my script : public class Move : MonoBehaviour {
public CharacterController CC;
public Animator Ani;
float MoveSpeed;
float TurnSpeed;
Vector3 V3;
// Use this for initialization
void Start () {
MoveSpeed = 5f;
TurnSpeed = 2f;
}
// Update is called once per frame
void Update () {
V3 = new Vector3 (0, Input.GetAxis ("Mouse X"), 0);
transform.Rotate (V3 * TurnSpeed);
Ani.SetBool ("walk", false);
if (Input.GetKey (KeyCode.W)) {
CC.Move(transform.forward * MoveSpeed * Time.deltaTime);
Ani.SetBool ("walk", true);
}
if (Input.GetKey (KeyCode.A)) {
CC.Move(transform.right * -1f * MoveSpeed * Time.deltaTime);
Ani.SetBool ("walk", true);
}
if (Input.GetKey (KeyCode.S)) {
CC.Move(transform.forward * -1f * MoveSpeed * Time.deltaTime);
Ani.SetBool ("walk", true);
}
if (Input.GetKey (KeyCode.D)) {
CC.Move(transform.right * MoveSpeed * Time.deltaTime);
Ani.SetBool ("walk", true);
}
}
}
UnassignedReferenceException: The variable Ani of Move has not been assigned. You probably need to assign the Ani variable of the Move script in the inspector. UnityEngine.Animator.SetBool (System.String name, Boolean value) (at C:/buildslave/unity/build/artifacts/generated/common/modules/AnimatorBindings.gen.cs:270) Move.Update () (at Assets/Scripts/M
Attach your animator to gameObject then drag this gameobject to "Ani" in inspector. @ kojunha
Answer by Wolfshadow · Sep 07, 2015 at 09:25 PM
Anytime a variable is public, you will be able to see it in the inspector
Your answer
Follow this Question
Related Questions
How can I fix this error(warning)? 1 Answer
Error stage @username 1 Answer
Can't add Orbital script - "The script needs to derive from MonoBehaviour!" 0 Answers
Create a copy of a non MonoBehaviour class and set variables from other class 0 Answers
ArgumentOutOfRange: Argument is out of range Parameter name: index 0 Answers