Answer the question
In order to leave comments, you need to log in
[Unity2D] How to fix [script]jump while taking damage?
The problem is that when receiving damage (any) and pressing the spacebar (jump) during the damage received, the character jumps very high, but it is necessary that when receiving damage, the character only repels and it is not possible to use the jump when the character is damaged.
Jump method:
private void Jump()
{
rigidbody.AddForce(transform.up * jumpForce, ForceMode2D.Impulse);
}
public override void ReceiveDamage()
{
Lives--;
rigidbody.velocity = Vector3.zero;
rigidbody.AddForce(transform.up * 6.0F, ForceMode2D.Impulse);
Debug.Log(lives);
}
private void CheckGround()
{
Collider2D[] colliders = Physics2D.OverlapCircleAll(transform.position, 0.3F);
isGrounded = colliders.Length > 1;
if (!isGrounded) State = CharState.Jump;
}
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question