Hi newbie here, so my character object has a single jump mechanics , I just noticed the whenever I press the jump button many times quickly in which the character is near a “staircase , boxes or even sometime near the edge of a platform (while also being up in the air and pressing jump)” it starts to fly off beyond my jump force. anyone can teach and help me to fix this physics? thanks
void Update () {
JumpRequest();
}
void FixedUpdate() {
Jump();
JumpOptimization();
isGrounded = Physics2D.OverlapCircle(feet.position, groundradius, groundlayers);
}
public void JumpRequest() {
if (CrossPlatformInputManager.GetButtonDown("Jump") && isGrounded)
{
isGrounded = false;
Jumprequest = true;
}
}
void Jump()
{
if (Jumprequest)
{
mybody.AddForce(new Vector2(0, jumpforce) , ForceMode2D.Impulse);
}
Jumprequest = false;
}
void JumpOptimization() {
if (mybody.velocity.y < 0)
{
mybody.gravityScale = Fallmultiplier;
}
else
{
mybody.gravityScale = 1;
}
}