private void Update() { if (Math.Abs(personageRB.velocity.y) >= 0.1f) { onAir = true; } else { onAir = false; } if (vidas.currentLives > 0) { if (Input.GetKeyDown(KeyCode.Space) && !onAir) { personageRB.AddForce(new Vector2(0, velocidadSalto), ForceMode.Impulse); personageRB.velocity = new Vector2(personageRB.velocity.x / 2, personageRB.velocity.y); playerAudio.PlayAudio(0); aController.ActivateJump(); } float impulsoActual = impulsoHorizontal; if (onAir) { impulsoActual /= 10; } if (Input.GetKey(KeyCode.RightArrow)) { transform.eulerAngles = new Vector3(0, 90, 0); if (personageRB.velocity.x < velocidadHorizontal) { personageRB.AddForce(new Vector2(impulsoActual * StaticComponent.GetCurrentSpeed(), 0), ForceMode.Force); } } else if (Input.GetKey(KeyCode.LeftArrow)) { transform.eulerAngles = new Vector3(0, -90, 0); if (personageRB.velocity.x > -velocidadHorizontal) { personageRB.AddForce(new Vector2(-impulsoActual * StaticComponent.GetCurrentSpeed(), 0), ForceMode.Force); } } else { personageRB.AddForce(new Vector2(-4 * personageRB.velocity.x, 0), ForceMode.Force); } } else { personageRB.AddForce(new Vector2(-4 * personageRB.velocity.x, 0), ForceMode.Force); } }