Quantcast
Channel: Questions in topic: "error message"
Viewing all articles
Browse latest Browse all 2891

Object reference not set to an instance of an object

$
0
0
I am doing a simple walk animation by following a tutorial he moves but the walk animation does not play due to the Object reference not set to an instance of an object error popping up for line 33 so the error is occurring in the if else statement but i cant figure out why. The boolean "isWalking" has been created in parameters and is set to the transition both ways. using UnityEngine; using System.Collections; public class malccontrols : MonoBehaviour { static Animator anim; public float speed = 10.0F; public float rotationSpeed = 100.0F; // Use this for initialization void Start () { anim.GetComponent(); } // Update is called once per frame void Update () { float translation = Input.GetAxis("Vertical") * speed; float rotation = Input.GetAxis("Horizontal") * rotationSpeed; translation *= Time.deltaTime; rotation *= Time.deltaTime; transform.Translate(0, 0, translation); transform.Rotate(0, rotation, 0); if (translation != 0) { anim.SetBool("isWalking", true); } else { anim.SetBool("isWalking", false); } } }

Viewing all articles
Browse latest Browse all 2891

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>