I’m using splines/curves/Path3D to make a looping swim path for fish. I went off the tutorials I’ve found for moving a camera along a 3D Path, but I can’t seem to figure out a way to make it so the rotation is smoothly reset at the end/beginning of the loop. If you check this playground https://playground.babylonjs.com/#MQAXMZ#3 You can see the fish “snap” from the bottom side of the curve to the top when the loop resets. How do you make it so the fish doesn’t do that? Bonus pts if there’s a way to make it so the fish always stays upright, above the curve. (not flip upside down as it moves down)
@carolhmj I can not remember how you solved this in your demo ???
Yeeeah ensuring spline continuity is a tricky little thing, my Path3D demo is not a continuous curve so I ended up not having to solve that. To make the path smooth on the loop, you have to guarantee that the normal and binormal vectors are the same in the start and end, which is not something that the Catmull-Rom offers automatically. The above’s suggestion of computing the rotation with the next point instead of the current one is a possibility. Another one would be to, instead of using a closed curve, to use an open one with the first and second points added at the end (so it’s kind of a loop that continues on the next point), and then discard the last point on the curve when creating the path: Fish on path | Babylon.js Playground (babylonjs.com)
One material I will always recommend about curves is Freya’s masterpiece: The Continuity of Splines - YouTube it helps a looot to visualize these concepts of continuity in your head
I found that the rotation parameters at the end and the beginning were different, so I changed them and now they are completely smooth.
Fish on path | Babylon.js Playground (babylonjs.com)
Nice! And the fish stays upright as well! Thanks~