[Leapy] Implementing the frog jump


I did a small scene and started working on the frog jump.

The idea is to click and drag on the screen and the further you drag the longer the jump. Later i will implement a visual feedback to be able to measure how much are you draging the mouse.

Since i can't make a jump animation, i did a scale increase and decrease to simulate the forg getting height.

I achieved this with the following:

On the update method i check for left clicks and releases.

Upon pressing left click, it gets the current position of the screen: 


Upon releasing, it get the position of the release and calculates the force to be applied to the jump. But instead of appling the force to the rigidbody of the frog, i use it to calculate where will be the position at the end of the jump. Then i call a Coroutine with the initial and final position. This Coroutine will take care of the movement and "animation".

The Jump:


This method will make a Lerp of the position and the scale  of the frog. The sprite goes up on scale until the time reaches half the duration of the transition and then starts going down on scale.

Get Leapy

Download NowName your own price

Leave a comment

Log in with itch.io to leave a comment.