So I’m using the :lerp() equation to do some smooth movement on the client side. When a turn is required I do this local cFrame = CFrame.new(LerpPosition) * CFrame.Angles(0,math.rad(LerpRotation.Y),0)
to do some smooth rotation, however the problem I’m dealing with is the Orientation for Parts being from -180-180. And since lerp is a linear the Orientation it gives isn’t correct. For example to go from -180 to 180 it would obviously go to -179 -178 etc however -180 and 180 face the exact same way. I want to make it so instead of it going from 180 to -179 it goes to 181. Is there a way to do this via code or something other way?
I had this same problem.
Look at the solution in the post:
Thank you to @mc7oof but I did figure out better way imo that’s a lot simpler to do a full 360:
local function ConvertOrientation(Rotation:number)
if Rotation< 0 then -- Only do this if the Orientation is under 0/negative
return 180 + (Rotation+180) -- Gets the difference between the Rotation and 180 since 180 is the highest rotation possible. You + and not - because the Rotation is negative. Then add 180 so that it gives that 360 degrees we want
else
return Rotation
end
end
Isn’t it simplier and cleaner to just do
local function ConvertOrientation(Rotation:number)
return Rotation % 360
end
2 Likes
This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.