#GetComponent on null references
1 messages · Page 1 of 1 (latest)
when you do playerRB.GetComponent<Rigidbody2D>(), you're asking playerRB to check the game object it's attached to for a Rigidbody2D component.
but playerRB is null
so it throws an error
GetComponent<Rigidbody2D>() is equivalent to writing this.GetComponent<Rigidbody2D>()
This makes your component ask its game object if it has a Rigidbody2D on it
