I am trying to set up a function that adds a jump boost to the main character when a jump potion is used, but unity crashes whenever I use the potion. This is the code inside of the JumpBoost function.
public void JumpBoost()
{
int boostTime = 15;
float boosted = 0f;
boosted = Time.time + boostTime;
while(Time.time < boosted)
{
jumpForce = 3f;
}
jumpForce = 2f;
}
And this is how I am calling the function:
case 3:
{
player.GetComponent().JumpBoost();
break;
}
}
I am getting no errors when compiling and the game will run fine so I assume its something with my while loop, but it shouldn’t be an infinite loop. I’ve tryed adding a delay inside the while loop also, but that didn’t help at all. Thanks in advance for anyone who can help me