-
Notifications
You must be signed in to change notification settings - Fork 42
Description
Hello!
Thank you for creating this library, I am using it in an attempt to make a small 2d car game with replays in Unity.
I am neither a very good programmer or good at maths, so this might just be me using the library incorrectly. I also have no solution or any idea what could be wrong - if anything is wrong. I tried looking at the code in this library but I'm not sure what's going on. Sorry.
However, I have discovered that strange things happen to values that make use of fpmath.atan2.
I used the code from here to make my car turn, and if I use the regular Mathf.Atan2 it works fine, but not with fpmath.atan2.
I also tried converting an atan2 method I found here into this:
fp Atan2(fp y, fp x){
fp a = 0;
if(x > 0){
a = fpmath.atan(y/x);
}else if(x < 0 && y >= 0){
a = fpmath.atan(y/x) + fpmath.PI;
}else if(x < 0 && y < 0){
a = fpmath.atan(y/x) - fpmath.PI;
}else if(x == 0 && y > 0){
a = fpmath.PI_OVER_2;
}else if(x == 0 && y < 0){
a = fpmath.PI_OVER_2_INV;
}
return a;
}
If I use that method the car behaves as expected. Not sure what to do next, I have never created an Issue on github before.
Sorry again for not being very helpful. Let me know if more details are needed.