What's wrong with this Pogo stick script?

I’m making a game where you control a pogo stick that bounces off any surface. This is the script I made for it.

public float gravity;
public float fallAccel = -1;
public float jumpForce = 1;
public float fallSpeed;

public Collider2D spring;
public Collider2D stickBody;

void Update()
{
gravity += fallAccel;
transform.Translate(0, gravity, 0);
}
void OnColliderEnter2D(Collider2D spring)
{
gravity = jumpForce;
}

When the Spring of the stick touches any collision, its vertical velocity (gravity) turns positive making it bounce. The problem is that the pogo stick falls through any terrain, despite them both having colliders that aren’t triggers.

Check the API callback name carefully. :slight_smile:

Also, when you post a code snippet, always use code tags:

How to use code tags: Using code tags properly