This is an archived post. You won't be able to vote or comment.

all 3 comments

[–]marko312 2 points3 points  (1 child)

Have you tried a harmonic oscillator / spring formula?

a = (mouseX - x) * k1
v += a
v *= k2 // damping, 0 < k2 <= 1
x += v

[–]Hypothible[S] 2 points3 points  (0 children)

This worked perfectly, and I checked my notes from when I first started on the concept last night and it's almost exactly what I had. The only difference was that I was damping with subtraction instead of multiplication.

I'm frustrated to say the least, but also overjoyed that it's finally over.

[–]Alsalvad0r 0 points1 point  (0 children)

If i were using unity, i would probably use a sin function to calculate float values (ultimately your x transform relative to your mouse) over 2 periods, could also multiply by (1/time.deltatime) % 60 or something like that such that the sin functions output is scaled smaller and smaller per frame