0

i new to Unity3D, so i take look to tutorials, and bump into issue with error linked in tittle of this thread. So. i Wrote exactly code that this guy wrote, and do also exactly what he do, but get error. I add rigidbody to mine player object. Here picture: enter image description here

Tutorial: http://unity3d.com/learn/tutorials/projects/roll-a-ball/set-up?playlist=17141

1 Answers1

1

Are you sure the setup() function is ever called, which initializes the rb variable? It seems like this is variable, which is null. Try to replace rb.AddForce(mouvment * speed) with GetComponent<Rigidbody>().AddForce(mouvement * speed);. Alternatively, rename your setup() function to Awake() or Start().

Maximilian Gerhardt
  • 4,872
  • 3
  • 20
  • 42