The basics:
I wanted to make a physics based movement thing. It uses the built in AngularVelocity
BodyMover
.
It keeps the angular velocity at a specific value if the force acted on it is not large enough.
The balance:
I give a target CFrame
and it gives the offset (in degrees) from the current body CFrame
. Then i made a curve to make the speed less the closer it gets to the target.
Basically this curve.
The problem:
The character overshoots, oscillates and stabilises. If it decides to stabilise.
Possible solutions:
I was thinking of somehow including the base angular velocity of the object (the velocity it already rotates at) to compensate. But as to how? I don’t know.
The equation looks like this:
function Curve(Current) --this is applied to all of the offset axes (x,y,z)
local Result = (Current^2)/360 --360 is just the max offset value (180 to -180 is but it works differently in practice)
if Current == math.abs(Current) then --differentiate between backward and forward
return Result
else
return -Result
end
end
Any and all help is appreciated. Thank you in advance.
BodyGyro
is not suitable for my use case.