I am animating a character using solely math, that is to say using sine and cos functions to give it movements. However, I have run into a problem in that for some reason my sine and cos waves are being really inconsistent, sometimes when I load the game they are super exaggerated and sometimes they are barely visible. Not to mention, my sine waves seem to only go positive and back to its original position, never dipping into negative:
You are using the rotation in object space formula so it will change direction depending on the previous c1 and perhaps even .Transform animation property.
Consider or try using rotation in world space axis if you want it more consistent.
Hi, sorry I should have made this more clear but I am using cos even though it’s called sine, it was previously sine but i was having the same problem so it doesn’t matter anyways.
Use a time of measurement different from tick(). There’s no reason your wave should be in the range between -0.1 and 1 without something having gone wrong like the frame rate limit messing with your function output
Actually your sine variable shouldn’t even above 0.2 because that’s the radius you defined. Something else has gone wrong or you’re expecting a different result from a function you wrote incorrectly
Whats wrong with tick? I need to use tick as this function updates evey frame to make it animate, also yes it is inbetween .2, I just used 1 as an example in the photo above
There’s nothing wrong with tick(), I was just concerned about your issues coincidentally lining up with symptoms of a fixed interval. For example, running a cosine function every 6.28 milliseconds would result in the same output every time
Now that we know the function output isn’t what you wrote, make sure that you are converting units properly. Remember that 2pi is 1 full loop around the circle. In the current function, 1 millisecond is 32% of the circle/loop for your animation. You will likely end up writing a ratio, something like 1/(2pi) to represent 1 second per loop