I’m currently working on a custom camera controller. The camera’s rotation can be set by right-clicking and dragging, but when the player lets go it lerps back to the character’s orientation.
Let’s say the character’s orientation is at 20 degrees, but the camera is at 290 degrees. I need to make the lerp go from 290-> 0 → 20 in order to make it smooth.
I’ve tried doing this, but because of the easing of lerping it is not smooth.
I’ve tried many things to get this to properly work, but I can’t seem to get it working properly.
Here is my code:
Any insight is appriciated, I’ve messed with this for about an hour now and its driving me crazy.
-- Rotate Camera -- if isHoldingRightClick then local delta = UIS:GetMouseDelta() local rotate = delta.X * cameraSensitivity angle += rotate clampAngle() else local orient = root.Orientation.Y if orient < 0 then orient += 360 end local distance = math.abs((angle + 180) - orient) print(distance) --if distance > 180 then -- ??? --else -- angle = IntegerLerp(angle, orient, 0.1) --end clampAngle() end