godot-docs icon indicating copy to clipboard operation
godot-docs copied to clipboard

Fix smooth follow example in interpolation

Open aXu-AP opened this issue 1 year ago • 1 comments

Old method is not really frame-independent. Formula with explanation found from here.

aXu-AP avatar Sep 03 '22 19:09 aXu-AP

Notice: I tested the code only in 3.x build, then changed linear_interpolation to lerp. I think there shouldn't be any other changes between 3.x and 4.0. Also C# code is untested.

aXu-AP avatar Sep 03 '22 20:09 aXu-AP

Adding link since OP hasn't https://docs.godotengine.org/en/latest/tutorials/math/interpolation.html I tested current implementation in 4.0 beta2, and then tried yours (so I tested both versions)

The version currently at the docs does interpolate evenly but it jitters. Your version is better as its smooth without jitter. I don't like that the code is slightly more complicated (newbies will use it but won't understand it, compared to current version), but the results are worth it imo.

TheYellowArchitect avatar Oct 05 '22 17:10 TheYellowArchitect