I need help on disabling the camera movement in a top down game
https://gyazo.com/44d842f60adfa4a581344953ad0320fb
You can see that the player can move the camera slightly, which isn’t normal for a top down view
1 Like
Are you using a while loop to update the camera?
Change the camera type to Scriptable
2 Likes
No here is the script
local offset = Vector3.new(-40,70,0)
local fieldOfView = 90
local player = script.Parent.Parent
local camera = game.Workspace.CurrentCamera
local runService = game:GetService("RunService")
camera.FieldOfView = fieldOfView
local function onRenderStep()
local playerPosition = player.Character.HumanoidRootPart.Position
local cameraPosition = playerPosition + offset
camera.CoordinateFrame = CFrame.new(cameraPosition, playerPosition)
end
runService:BindToRenderStep('Camera',Enum.RenderPriority.Camera.Value,onRenderStep)
2 Likes
Add this to your code:
camera.CameraType = "Scriptable"
3 Likes
Like @ThousandDegreeKnife said. Setting the CameraType property to “Scriptable” is probably exactly what you’re looking for.
You should check out some of the other cameraTypes, maybe you can find a more desirable method for the job. Like if you used Enum.CameraType.Follow
you can have the player still rotate the camera in a top down view.
Also you might want to ensure that the character has loaded before the rest of the script runs, otherwise things can break.
local offset = Vector3.new(-40,70,0)
local fieldOfView = 90
local player = script.Parent.Parent
local character = player.Character
if not character or not character.Parent then
character = player.CharacterAdded:wait()
end
... the rest of your code ...
4 Likes