I came across an interesting problem during that work. I have an object that moves following a sine wave.

And when i change its frequency, the object jumps up and down to where it would have been if it was at that frequency.

I have an idea on how to solve this. But I'll need to experiment with it.

@Oliviastarstuff If it helps, I've solved that exact problem before by treating the input as a radial angle (-pi to pi) instead of a linear input (time). Once the input is essentially a closed-loop circle, it becomes pretty easy to interpolate properly between two points.

@LouisIngenthron I'm not sure I understand. Is there material I can read?

@Oliviastarstuff That's okay, it's wrong anyway. 🤦‍♂️ 😆 Sorry, I was thinking of a different, but similar problem.

Your issue can be solved by tracking the time variable separately.

Instead of multiplying by the frequency by the time value when you feed them into the sin wave, store your own separate timer value and when you increment it each frame, multiply that increment by the frequency.

That way it will retain a consistent state between update frames, regardless of any jumps in frequency/timescale.

Sign in to participate in the conversation
Qoto Mastodon

QOTO: Question Others to Teach Ourselves
An inclusive, Academic Freedom, instance
All cultures welcome.
Hate speech and harassment strictly forbidden.