I'm making a 2d platformer game using c# and I've got this error message that I don't understand how to fix it. There aren't any red squiggly lines under the code.
Here's the error message:
NullReferenceException: Object reference not set to an instance of an object
Bounce_pad.OnTriggerEnter2D (UnityEngine.Collider2D other) (at Assets/Sripts/Bounce_pad.cs:14)
----------
Here's the code I'm currently using:
private Rigidbody2D rigidbody2d;
void OnTriggerEnter2D(Collider2D other)
{
if (other.tag == "Player")
{
float BounceHeight = 10f;
rigidbody2d.velocity = Vector2.up * BounceHeight;
}
}
↧