- Home /
Nullreferenceexception on roll a ball project
I am incredibly new to unity, just downloaded it this morning and jumped right in with the roll a ball project. I'm starting to get the impression this was the wrong place to start. I have followed the tutorial step by step and copied his code word for word but am still getting this error message:
NullReferenceException: Object reference not set to an instance of an object PlayerController.FixedUpdate () (at Assets/scripts/PlayerController.cs:22)
Here is the script:
using UnityEngine; using System.Collections;
public class PlayerController : MonoBehaviour {
public float speed;
private Rigidbody rb;
void start ()
{
rb = GetComponent<Rigidbody>();
}
void FixedUpdate ()
{
float moveHorizontal = Input.GetAxis ("Horizontal");
float moveVertical = Input.GetAxis ("Vertical");
Vector3 movement = new Vector3 (moveHorizontal, 0.0f, moveVertical);
rb.AddForce (movement * speed);
}
}
Now, im gonna take myself off and learn a bit about scripting before even coming back to this thing, but for the sake of my sanity, can someone please tell me where i went wrong?
Answer by dreinzy · Apr 24, 2015 at 07:08 AM
Your void **S**tart isn't capitalised...
I can't believe i missed something so simple, i went over it about 40 times as well. Thank you for spotting it!
I had this same problem! I was quite frustrated, but wow, that simple capital S huh... Godly answer!
Thanx! I dint even notice that while going through the code again and again :D
you should use code comparison with the demo one
you're awesome man! you prevented me from giving up unity! :D
Follow this Question
Related Questions
Null Reference Exception ? :/ 1 Answer
AddForce relative to camera rotation 1 Answer
Weird bug. Roll a ball project 0 Answers
what is wrong with my script?!?!?! 1 Answer
How to create a rolling sound that only plays when object is moving? 2 Answers