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

Why is using GetComponent(CharacterController) causing null reference exceptions?

$
0
0
Alright, I'm attaching this script to a GameObject named 'test' which has a character controller. Every frame it prints "Null" AND "test(UnityEngine.CharacterController)" This is doing two things. Firstly it's giving me a Null Reference Exception every frame. Secondly it's confusing the hell out of me. Why this is being called up twice every frame? And why is one of them always null? Thanks for the help! #pragma strict var controller : CharacterController; function Start() { controller = gameObject.GetComponent(CharacterController); } function Update() { print(controller); }

Viewing all articles
Browse latest Browse all 171066

Trending Articles



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