Hello, I am working on a VR game where the player does not have 1:1 control over their hands. Instead, the VR controllers act as a goal that the in-game hands will interpolate towards. (For the curious—this is the game.) Currently, we are using linear interpolation. This works will for when the goal is travelling in a straight line, but when it arcs (which is very often, since our arms primarily move in arcs), the hands will take a shortcut. This is undesirable for our gameplay, as it often makes players feel their arms are shorter than they are.
https://gfycat.com/indolentwelloffcaiman
An improvement over this is to follow the goal by storing a list of its positions over time.
https://gfycat.com/astonishingqueasybarebirdbat
This works very well for standard arcing motion, as seen in the first half. However, in the second half we can see that following the goal exactly causes the hands to zig-zag as they approach the goal—this is also undesirable behaviour.
To solve this problem, I am looking for a curve fitting algorithm that, given the blue curves below (represented as lists of positions) would produce something similar to the green curves.
![](https://uploads.gamedev.net/forums/monthly_2020_06/d69b5c594ff34a6cbb106b03a8d1a173.image.png)
The requirements I'm thinking are that the output curve would
- Attempt to fit the input curve, but the angle between adjacent points would never be allowed to be greater than some constant (as we can see in A and D). I did a rough pass on this where I trim any edges that do not satisfy this requirement.
- Not be allowed to “double back” on itself, as seen in B and C.
^^2 is the one I am struggling with. I am searching for a curve fitting algorithm that would somewhat fit (ha) these requirements. I am not concerned with performance, as for the foreseeable future there will only be two objects in the world (the hands) running this code.
Thanks for any replies!