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

How come when I set my camera to scriptable, it becomes much much more slippery?

Asked by 6 years ago

To help you understand, I have a script that makes your camera look at where you mouse is.

It works really well when the camera is set to default, however if you were to try it with a scriptable camera type, you'll see that the camera will work much more differently than before.

I'll show my script here.


local RunService = game:GetService("RunService") local InputService = game:GetService("UserInputService") local Player = game.Players.LocalPlayer local Camera = game.Workspace.CurrentCamera local Mouse = Player:GetMouse() local CameraOffset = Vector3.new(0, 40, 20) local Aiming = false InputService.InputBegan:connect(function(Input, Processed) if not Processed then if Input.UserInputType == Enum.UserInputType.MouseButton1 then Aiming = true end end end) InputService.InputEnded:connect(function(Input, Processed) if Input.UserInputType == Enum.UserInputType.MouseButton1 then Aiming = false end end) RunService.RenderStepped:connect(function() Camera.CameraType = "Scriptable" -- REMOVE THIS PART IF YOU WANT TO SEE -- HOW IT SHOULD BE WORKING local Character = Player.Character local HumanoidRootPart = Character:FindFirstChild("HumanoidRootPart") if HumanoidRootPart then local PlayerPosition = HumanoidRootPart.Position local MousePosition = Mouse.hit.p local RelativePosition = CFrame.new(PlayerPosition):toObjectSpace(CFrame.new(MousePosition)).p local X, Z = RelativePosition.X, RelativePosition.Z local CameraPosition = PlayerPosition + CameraOffset if Aiming then Camera.CoordinateFrame = CFrame.new(CameraPosition, PlayerPosition) + Vector3.new(X, 0, Z) else Camera.CoordinateFrame = CFrame.new(CameraPosition, PlayerPosition) end end end)

Simply remove the line that makes the camera type scriptable to see how it was meant to work, then just click away with the left mouse button to see it in action.

Thank you!

Answer this question