I want to limit my jumpPressure value within 10f, but as I multyply it by Time.deltatime*.3f, it gets higher every seconds.
Code below to have a look , thanks in advance
{
private Rigidbody2D playerRb;
public float jumpPressure = 0f;
private float intialJump = 80f;
void Start()
{
playerRb = GetComponent();
}
void Update()
{
{
if (Input.GetButton("Jump"))
{
{
jumpPressure += Time.deltaTime * .3f;
**// This is where the jumpPressure is getting too high every seconds and affecting my Addforce below//**
}
}
else
{
while (jumpPressure > 0)
{
jumpPressure = (Time.deltaTime * -7f);
}
}
}
playerRb.AddForce(Vector2.up * intialJump * jumpPressure, ForceMode2D.Force);
↧