[Leapy] Landing on lilypads


To check if the Frog lands on a lilypad i started by adding a CircleCollider2D to both and set it as trigger.

I added a bool variable "jumping" to the DragAndShoot script and set it to true while the jump is being done and when it ends it set it back to true.

This way, in the update method of the Frog, it checks if it's jumping or not. If it is jumping it disables his CircleCollider2D with the idea to not collide with the lilypads while it's in mid-jump. When the frog lands, the CircleCollider2D is enabled again.

The Frog now has 2 additional methods: OnTriggerEnter2D and OnTriggerExit2D to check the collisions.

When it collides with a lilypad, the frog sets his parent to this lilypad. This way, if the lilypad is moving, the frog will move aswell.

When the frog leaves the lilypad, his parent is set back to null.

Frog script:


This is the result:


Get Leapy

Download NowName your own price

Leave a comment

Log in with itch.io to leave a comment.