While writing my script, I wrote:
public Rigidbody rb;
But when I try to start the game in unity; it says that I have not assigned rb variable on my script.
While writing my script, I wrote:
public Rigidbody rb;
But when I try to start the game in unity; it says that I have not assigned rb variable on my script.
You need to drag your rigidbody into the rb slot in the inspector to assign it. Other unity gets confused and doesn’t know which rigidbody you’re talking about.
You can use:
void Start()
{
rb = GetComponent<RigitBody>();
}