How to detect if a part is moving in a curved path?

I currently have a part that moves along a set of nodes/waypoints and can rotate freely. I want to be able to detect whether the part is going through a turn or moving in a straight line, and if possible detect how sharp the curve/turn is.

Example of path:
turn

Since the part can rotate freely I can’t use any information about where the part is facing, ex. LookVector.

How would I achieve this? Any help is appreciated.

How exactly is the part moving? Are you lerping this part between each node?

You can use math.atan2 (take me lightly, I’m not a mathematician) with each pair of nodes within a section, to calculate the angle (will give radian, use math.rad or math.deg to convert) between the nodes. You can then add all the angles within the section, and use a threshold to determine if the section is curvy enough to be considered a turn/curve. I do NOT know how you have these nodes/waypoints set up, whether there’s only a node for each turn or every few studs, but this is just an idea with a lot of possible problems.

Setting the part’s velocity manually and using a VectorForce

I already have a solution for this using information provided by the nodes, however this can provide inconsistent results to what I’m trying to achieve, so I want to make a new system for it using only information about the part’s velocity/position.

Another idea is to track the velocity, if the X-axis considerably goes lower and the Z-axis does the opposite (vice-versa) consistently within a time span, then you could consider it a turn/curve. Instead of using a time-span you can set time points (like mark down the velo every half second into an array depending on how fast it’s going), and compare the velocity of the object to the past velocities marked in the previous few time points. I probably did a bad job of explaining this idea

I get what you are suggesting, how would I check if the velocity is going in different directions though?

If what I’m assuming is correct, the VectorForce is describing the direction the object is moving regardless of the object orientation? If this is the case, and without relying on nodes, you could store the VectorForce vector per frame, and every following frame, you could utilize the dot product theorem to obtain the angle between the last known vector and the current vector every frame. That way, you can at least detect if the object is currently turning or going straight.

1 Like

Thank you man, I suck at explaining stuff at times. If he’s using FloatCurves to connect the nodes then he could track and compare the Tangent or AssemblyAngularVelocity instead.