Hello. I was wondering how to make a office camera system similar to that of FNAF Plus? By that, I mean a camera that moves on an X and Y plane with the mouse.
Link FNAF plus- Gameplay official with sound - YouTube
Thanks!
Oh my god, that’s what I meant to put this in, sorry.
This is most likely the solution for you: https://devforum.roblox.com/t/how-do-i-make-camera-follow-player-mouse/973208/6
The code doesn’t work in first person, sorry.
What about it doesn’t work? I just tried it in studio in first person and it works fine.
It just freezes the camera in place.
What’s your CameraType set to? It would freeze in place if it wasn’t either Custom
or Scriptable
. Try adding this:
local RunService = game:GetService("RunService")
local Players = game:GetService("Players")
local camera = workspace.CurrentCamera
local mouse = Players.LocalPlayer:GetMouse()
Players.LocalPlayer.CameraMode = Enum.CameraMode.LockFirstPerson
camera.CameraType = Enum.CameraType.Scriptable
Doesn’t work. When I move the mouse, the camera just jitters and returns to its original position.
It works fine for me in a new baseplate with only this, so the issue is that some other code that you wrote is conflicting with this new code, so I’d try looking into what could be breaking this new code.
You could have a part that follows a number based on a bar, just like the cameras in FNaF Plus.
Essentially, you have a bar, and a drag button.
You take the Drag Buttons X Position, you remove 0.5 (So 0 = Middle) and then multiply the number by say, 20.
0.5 * 20 = 10 degrees rotation.
CameraRotation = (Bar.Position.X.Scale - 0.5) * 20
You can do the same for the Y axis, you’ll just have to take the Drag Bars Y Position instead of its X Position.
You then apply the rotation offset to the camera part, and update the cameras CFrame.
The script controlling that is the only script in the game. I’ve found a script that seems to work, but you can’t move the camera far enough on the left and right sides.
local mouse = game.Players.LocalPlayer:GetMouse()
local cam = workspace.CurrentCamera
local camPart = workspace.CameraPart
local player = game.Players.LocalPlayer
local Scale = 2500
cam.CameraType = Enum.CameraType.Scriptable
game:GetService("RunService").RenderStepped:Connect(function()
local center = Vector2.new(cam.ViewportSize.X/2, cam.ViewportSize.Y/2)
local x = mouse.X - center.X / 2
local y = mouse.Y - center.Y / 2
local xOffset = x/Scale
local yOffset = y/Scale
local lookAtPoint = camPart.Position+camPart.CFrame.LookVector*5
local vector = Vector3.new(
lookAtPoint.X - -xOffset,
lookAtPoint.Y - yOffset,
lookAtPoint.Z - xOffset)
local result = CFrame.lookAt(camPart.CFrame.Position,vector)
cam.CFrame = result
end)
Hello! If you are still struggling with this issue, I think I have a solution!
First, create parts around where you want your camera for be centered. Insert three of them and put them to the left, right, and in front of where your character will be. Name them ViewLeft, ViewRight, and ViewMain and group them as a model.
Now create a ScreenGui
and make three frames that evenly divide your screen into three pieces. Name them the same as you named your view parts for the respective direction. Insert a LocalScript into each frame and put this code:
local TweenService = game:GetService("TweenService")
local Camera = workspace.CurrentCamera
local Views = workspace:WaitForChild("Views")
local Frame = script.Parent
local function TweenCamera(TweenTime, pos)
TweenService:Create(Camera, TweenInfo.new(TweenTime, Enum.EasingStyle.Linear), {CFrame = pos.CFrame}):Play()
end
Frame.MouseEnter:Connect(function()
TweenCamera(0.32, Views.YourViewPart) -- You need three scripts so one should include a parameter for ViewLeft, Right and Main.
end)
Finally, add one LocalScript to your ScreenGui and name it Camera. Type this code:
local Camera = workspace.CurrentCamera
local Views = workspace:WaitForChild("Views")
repeat task.wait()
Camera.CameraType = Enum.CameraType.Scriptable
until Camera.CameraType == Enum.CameraType.Scriptable
Camera.CFrame = Views.ViewMain.CFrame
Hope this helps!