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

How do I make the camera work properly?

Asked by 7 years ago
I made a camera manipulating script but it glitches out if you move the mouse to far to the sides or the screen. I'm trying to make a camera move smoothly and doesn't move so much.

Here's the script :

local plr = game.Players.LocalPlayer
local mouse = plr:GetMouse()

game.Workspace.CurrentCamera.CameraType = Enum.CameraType.Scriptable
game.Workspace.CurrentCamera.CameraSubject = workspace.CameraPart
game.Workspace.CurrentCamera.CFrame = workspace.CameraPart.CFrame

mouse.Move:connect(function()

        game.Workspace.CurrentCamera.CFrame = CFrame.new(workspace.CameraPart.Position,Vector3.new(mouse.Hit.p.x, mouse.Hit.p.y, mouse.Hit.p.z))

end)

I wanted to create like this (it isn't mine but I got inspiration from it) https://twitter.com/Preacherism/status/820396489440632832

Please help? Thank you

1 answer

Log in to vote
0
Answered by 7 years ago
Edited 7 years ago

Partial Answer - I explain here what's wrong, but I don't understand what you're going for enough to propose a solution.

I believe the reason for the behaviour you are describing is that when you move your mouse near the left side of the screen, you're asking the camera to look left. This then causes your mouse to point at something to the left of where it was previously, meaning that if you're still moving the mouse, the camera will now look even further left than before (even if you're moving your mouse up/down instead of to the left). To fix this, you need to use something other than "mouse.Hit.p"

For instance, the link you provided appears to be moving the camera's position from a central location based on the location of the mouse coordinates relative to size of the Roblox window.

Ad

Answer this question