- Home /
Mathf.Approximatley if statement
I'm having some trouble with an if statement recently. This is my code:
r-t == dif;
if(Mathf.Approximately(dif.x, -1)){
nx= true;
print ("Stuff");
}
Now, Stuff is printed, but nx is not made true? Which is strange, since the if statement is definitely working. I'm not setting it to false anywhere else, btw.
Because it's in the inspector. Should be a comment, perhaps?
Having looked at it a bit more, I realised that it was printing because I didn't have { } in. So is there something wrong with this piece of code, or is the bug somewhere else?
Do you have some more code that you can show? from what it looks like above, the if will eval to true if the value of dif.x and -1 are the same. The logic looks good, maybe check the value of dif.x someplace. what is the r-t == dif for? That will eval to true or false, but doesn't seem to be used here.
Your answer
Follow this Question
Related Questions
Need help with undocumented Mathf.PerlinNoise 1 Answer
Implementing mathf ? 1 Answer
problem with mathf function 2 Answers
Rounding to the nearest int as a Result of a Function? 1 Answer
Does Mathf.PingPong always have to start at (0,0,0)? 1 Answer