I am looking for a way to design a scalar that goes from -1 to 1 dependent on the rotation of an object.
90 = -1
180 = 1
270 = -1
0/360 = 1
How might I go about this? Math is not my strong suit and any help is appreciated!!
Edit: I realize a scalar may be the incorrect name for something like this, but I'm not sure what the correct term would be. Happy to learn!
Develop games in your browser. Powerful, performant & highly capable.
You could utilize sin(), it goes from -1 to 1 as well as smoothly inbetween.
So you’d start with
Shift it over so when x=0 it will be 1
Next change it so it goes from -1 to 1 every 90 instead of 180.
You could also use cos() instead. It’s just 90 off from sin()
If you don’t want the smooth transitions inbetween you could utilize some rounding.
Hope that helps.
Thank you R0J0hound ! That sounds like exactly what I'm hoping for. Thank you for your help!