Question by
jlorenzi · Feb 27 at 12:56 AM ·
scripting problem
Code Ignores if Statement
I'm making a dash mechanic and I don't want the player to be able to dash multiple times, so I made a bool called 'usedDash' and set it to false when the player touches the ground, and true when he dashes so it won't repeat. But somehow the code is just completely ignoring the if statement I put in my code that stops the dash from happening if the 'usedDash' bool is true. // DETECTING SPACE BAR PRESSES if (Input.GetButtonDown("Jump")) { pressCount++;
jumpRememberTimer = jumpRememberTime;
}
// DETECTING DOUBLE SPACE BAR PRESSES
if(pressCount > 0)
{
elapsedTime += Time.deltaTime;
}
if (elapsedTime > doubleTapTime)
{
elapsedTime = 0;
pressCount = 0;
}
else if (pressCount == 2 && states == States.dashing && !usedDash)
{
usedDash = true;
Dash();
elapsedTime = 0;
pressCount = 0;
}
void Dash()
{
addForce.AddImpact(transform.forward + transform.up, dashPower);
gravity = dashGravity;
}
Comment
Your answer
Follow this Question
Related Questions
example of new way to load levels 1 Answer
"The associated script cannot be loaded" 0 Answers
Global Illumination at Runtime 0 Answers
A graph to render sine wave with custom resolution 0 Answers
only menu1 hides on gui click 1 Answer