Question by
Elias_uchiha · Oct 10, 2016 at 02:31 PM ·
error message
hey guys im new to unity and im tryng to do the roll a ball and i have this error can anyone help? :(
NullReferenceException: Object reference not set to an instance of an object PlayerControler.FixedUpdate () (at Assets/_seanes/Materials/Scripts/PlayerControler.cs:20)
Comment
You need to show us your PlayerControler.cs (line 20 in particular, which is what's producing the error).
Answer by Landern · Oct 10, 2016 at 05:36 PM
You need to change the spelling of your "start" method. The rigidbody isn't being found(so the rb variable remains null) because of the case sensitivity of the Unity method. So change:
void start ()
to
void Start ()
with a capital "S"
You might also want to add the parenthesis in the start method when invoking GetComponent.
change:
rb = GetComponent<Rigidbody>;
to
rb = GetComponent<Rigidbody>();