Getting a Sine wave to match up with specific values

I’ve been trying to this all day, and it’s been some years since I took a math class, so bear with me.

I need it so that I get points like the following: {(4,1),(8,-1),(12,1),(16,-1)…} Pretty much every 4 units on the X axis the Y value fluctuates between positive and negative 1. (The number on the X axis would be supplied by me, and the number on the Y axis is the number I would like returned)

I know that a Sine wave would probably do the trick, but I just can’t seem to figure out how to use it in this situation. If it didn’t need to land on specific points, it wouldn’t be such a problem.

If I put my graphing calculator in Degree mode instead of Radian mode: sin(90) = 1.
If I put it in Radian mode: sin(90) = 0.89399…

So I figured “1” was sin(90) in Degrees, and “0.89399…” was sin(90) in Radians, which seemed to make sense at the time. If I could get sin(90) to equal “1” in Unity, I could make things work by resetting my X value after getting to a certain point, and multiplying X by 90 to get the Y value i needed.

I tried converting the “0.89399…” into Degrees, and got “51.22185393”, which was definitely not the expected result. I even used a converted on Google to ensure that it was not just me programming it incorrectly.

Really all I need to know is how to make sin(90) = 1, and I can take it from there.
Any help would be greatly appreciated.

The Unity Sin function is expecting the angle in Radians not Degrees, convert your angles to Radians using tghe Mathf.Deg2Rad constant then use the Sin function.

1 Like

Oh my god I’m such an idiot.
Thank you

Or just work in radians directly. 90 is equivalent to 0.5 * Pi