Quantcast
Channel: Latest Questions on Unity Answers
Viewing all articles
Browse latest Browse all 171066

CharacterController NullReferenceException dispite attached to object

$
0
0
Hi, I am writing a movement script using CharacterController. I have a characterController component attached to my object, but, it keeps returning a NullReferenceException. I have tried creating a new object as well as importing one of the example objects, but nothing seems to work. Below is all the code in the script that mentions the CharacterController. private var character : CharacterController; character = GetComponent(CharacterController); if(this.transform.position != standardPos) { var target : Vector3 = standardPos; target.y = transform.position.y; // keep waypoint at character's height var moveDirection : Vector3 = target - transform.position; if(moveDirection.magnitude < 1) { transform.position = target; // force character to waypoint position } else { Accelerate(); transform.LookAt(target); character.Move((moveDirection.normalized*speed)*Time.deltaTime); } }

Viewing all articles
Browse latest Browse all 171066

Trending Articles



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