Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

Help with lerping a camera to smooth movement?

Asked by
Edenojack 171
8 years ago

So I'm trying to smooth mouse movement utilizing lerping, this means I'm looking at two values;

The original CFrame

and the aimed CFrame.

I use a code like this:

Cam.CoordinateFrame = OrgCamCF:lerp(AimCamCF, 0.5) --(Psuedo code)

This presents two problems.

Firstly, the lower the lerp's percentage - while it is smoother - it means that if the player moves, they will move faster than the camera can adjust. Is there any way of using this to ensure I can not only smooth the mouse, but also ensure it stays centered in the players head?

Secondly, Moving the mouse with a lerp in a diagonal movement will cause the camera to rotate along its "relative Z axis". The faster the mouse moves, the more this rotation is noticable. I want to remove this, as it can cause motion sickness. Does anyone have any ideas on how to fix this?

If you can help me with either of these, either utilizing the lerp method, or by suggesting alternative methods, I'd be incredibly grateful!

1 answer

Log in to vote
0
Answered by
Tynezz 0
8 years ago

Seems like a problem, anyways try this:

for i=0,1,0.1 do
Cam.CoordinateFrame = OrgCamCF:lerp(AimCamCF, i)
wait()
end

Not only does this tweens smoothly but you can change the time, example:

for i=1,1,0.2 do --The increment is 0.2 instead of 0.1 it's faster and shouldn't see much of a difference.
Cam.CoordinateFrame = OrgCamCF:lerp(AimCamCF, i)
wait()
end
0
I've already got a system that changes how fast the camera moves, it works really well and adapts to how low the Focus of the camera is set. What I want to avoid is: the player moving away from the camera while in first person, the players camera 'tipping' when moving the camera dramatically. Edenojack 171 — 8y
0
If you explain more in-depth it would help. Right now your questiions are pretty vague. Tynezz 0 — 8y
0
Imagine a line, going right through a brick, from front to back. This is the bricks relative Z axis. You can rotate the brick in anywhich way, but that will forever be its Z. If I lerp the camera, the camera rotates slightly around its Z axis, giving an illusion of tipping. This can cause motion sickness, and is not something I want in my game. When I use lerping, the Camera Subject - In this case Edenojack 171 — 8y
Ad

Answer this question