If you put it in a loop, a RunService.Heartbeat function, or a mouse movement function with a tween, you should get the desired effect. Based on what I tried, a longer tweening time worked best to decrease the sensitivity of the camera to mouse movements.
I’m including the code I put together as an example, but you should check out Tweening and Camera Manipulation for more info on how this works:
This is exactly what I was looking for! Thank you! Only one thing, how would I make the camera only be able to move a certain distance and not continue to move and keep rotating when your mouse is on the side of your screen? (If you get what I mean)
I’d suggest using mouse.Move instead of RunService.Heartbeat. That way, it’ll only move the camera when the mouse moves (right now, it moves it every frame to match the mouse, even when it’s completely still).
As a simple solution, you might be able to define a max distance from the camera (or from any part, like the character’s head) that the mouse can point to. Right inside of the Heartbeat (or Mouse.Move, loop, etc.), you could have:
if (mouse.Hit.p - camera.CFrame.p).Magnitude <= maxDistance then
--camera tween like above
end
To get a more complicated solution that prevents turning more than a certain number of degrees in any direction, you’d probably have to check any new mouse position to see its offset relative to the current camera position.
Once you have that offset, math.atan() should help you get the intended angle.
I haven’t tested it, so I can’t guarantee that it’ll work, but it should get you started on the right track.
Sorry for this but maxDistance would be local maxDistance = math.rad(45)
I tried math.rad and math.atan, nothing seems to work?
Sorry once again, the answer is probably simple but I have no clue.
Thank you for you help~
Edit: In other words, how would you define maxDistance
Oops, I accidentally left that out of my previous response. I’d pick a maxDistance in studs (like 50) if you’re going with option 1. The problem you’ll end up with is that the mouse move when it hits areas close to the camera.
Edit: After some quick testing, neither method really looks good. In the video, the camera is attached to a single, predefined part or point in space. Without using the same setup, you’re not going to be able to achieve the same effect. If you decide to go with that setup, you’re going to have to do a little bit of trig (angles from side lengths) to constrain the possible viewing angles.