- Home /
Question by
George_1999 · Jan 05, 2015 at 08:28 PM ·
c#not workingif statement
Really weird problem with if statements [C#]
Here is my code if(Down==true) { axisV=-1; } else { axisV=0; } if(Up==true) { axisV=1; } else { axisV=0; }
The first if statement doesn't work at all but when i switch them (last first , first last) the last one doesn't work . how do i solve that ?
Comment
Best Answer
Answer by Mmmpies · Jan 05, 2015 at 08:43 PM
Looks like you're overriding any results from the first command with the second one's else statement. Try this:
if(Down!=true && Up!=true)
{
axisV = 0;
}
else if ( Down == true)
{
axisV = -1;
}
else
{
axisV = 1;
}
Not tested the code though.
Your answer
Follow this Question
Related Questions
Multiple Cars not working 1 Answer
Distribute terrain in zones 3 Answers
Why isn't my code for dashing working? 1 Answer
Does pattern matching verify object lifetime and null references 1 Answer