Hello everyone,
I have a problem and I don’t know how to solve it.
I have 2 UI Button on the canvas, one on the left and one on the right. And the left UI button will let the character jump to the left (-x, y), the right UI Button will let the player jump to the right (x , y).
I want to ask how to make the jump height depend on how long you hold button? The character is able to jump when the button is released.
Sincerely thanks.
RigidBody2D body;
public float fallSpeed;
Void Start()
{
body = GetComponent();
}
Void FixedUpdate()
{
if(body.velocity.y > 0 && !Input.GetButton(“Jump”))
{
body.velocity += Vector2.up * fallSpeed;
}
}
With this, if you’re not pressing Jump button when the player is getting up, you are going to be pushed down, change your “fallSpeed” float depending on how fast you want the player to go down