[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
Leapy
More posts
- [Leapy] Final version is live.Jul 29, 2022
- [Leapy] New graphics!Jul 27, 2022
- [Leapy] First playable version!Jul 25, 2022
- [Leapy] All the different lilypads so farJul 23, 2022
- [Leapy] Lilypad spawn system and changes in deleting off-screen lilypadsJul 22, 2022
- [Leapy] Sample GameOver screen and changes to landing on lilypadsJul 03, 2022
- [Leapy] Deleting lilypads off-cameraJul 02, 2022
- [Leapy] Lilypad object and first movementJun 17, 2022
- [Leapy] Repetitive backgroundJun 09, 2022
Leave a comment
Log in with itch.io to leave a comment.