public void SetForce(float force) { if (transform.localScale.x < 0) { RgbChar.AddForce(new Vector2(force * -1, 0)); } else { RgbChar.AddForce(new Vector2(force, 0)); } }
public void GetDamage(float damage, Vector2 posEnemie) { base.GetDamage(damage); spriteEffect.CancelEffect(); spriteEffect.StartInvunerable(); playerController.StartCoroutine(TimeDesactiveControlls(0.4f)); RgbChar.velocity = Vector2.zero; animChar.SetInteger("AnimState", 0); if (posEnemie.x >= transform.position.x) { RgbChar.AddForce(new Vector2(-directionKnowBack.x, directionKnowBack.y) * forceKnowBack); } else { RgbChar.AddForce(new Vector2(directionKnowBack.x, directionKnowBack.y) * forceKnowBack); } }
public IEnumerator GetKnowBack(float forceKnowBack, Vector3 posPlayer) { yield return(new WaitForEndOfFrame()); yield return(new WaitForEndOfFrame()); RgbChar.velocity = new Vector2(0, RgbChar.velocity.y); if (posPlayer.x >= transform.position.x) { RgbChar.AddForce(new Vector2(-directionKnowBack.x, directionKnowBack.y) * forceKnowBack); } else { RgbChar.AddForce(new Vector2(directionKnowBack.x, directionKnowBack.y) * forceKnowBack); } yield return(new WaitForSeconds(0.05f)); RgbChar.velocity = new Vector2(0, RgbChar.velocity.y); }
private void Jump() { if (isGround && !isAttacking()) { RgbChar.AddForce(new Vector2(0, forceJump)); } else if (!isGround && isWall) { if (transform.localScale.x < 0) { RgbChar.velocity = Vector2.zero; RgbChar.AddForce(new Vector2(500, forceJump)); } else { RgbChar.velocity = Vector2.zero; RgbChar.AddForce(new Vector2(-500, forceJump)); } } }