I have a worse case scenario where Unity does not read the if statement, this solely happens but this bug is very game breaking. For some reason it doesnt read when I do a very fast clicks “if(timer < .9f)” therefore it does not call the method ComparePos();
if (Input.GetMouseButton(0) && player_rb.velocity.y == 0 && enableInput) {
angle += (5f * Time.deltaTime) + .6f;
velocity += (2.1f * Time.deltaTime) + .1f;
path.tvelocity = velocity;
path.tangle = angle;
onGround = true;
timer += Time.deltaTime;
if (velocity >= velocityThreshold)
{
Jump();
enableInput = false;
angle = 0;
velocity = 0;
}
}
else
{
if (Input.GetMouseButtonUp(0) && enableInput) {
if (debugEnable){
Debug.Log("Angle: " + path.tangle + " Velocity: "+path.tvelocity);
}
Jump();
enableInput = false;
Debug.Log("Enable: " + enableInput);
if (timer < .9f) {
Debug.Log("Timer: "+timer);
cameraFollow.ComparePos();
}
}
}
This conditional statements are under the Update() function. I would like to know what are the ways to prevent this from happening or simply how to fix these kinds of problem.
Wrong
Right