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

How to vertically lock the camera angle, but not horizontally?

Asked by 1 year ago

I'm trying to make a dungeon game where the camera of a player can't zoom in or out (I've already done that part) but I need to make it so shift lock is always enabled (I can probably do that on my own as well)...

But I'm trying to make it so the player's camera angle can move left/right but not up/down, kind of like the "Orbital" roblox camera setting, the only problem is I'm trying to make the game a top down shooter, but I can't set the camera angle in the Orbital view.

I'm sure there is a simple way to vertically lock a camera angle, but I can't find it in the playersettings, there is only min/max zoom, what do I do?

For reference, the camera idea I'm going for is similar to this game's camera. https://www.roblox.com/games/9207492417/Rogue-Nightmare

1 answer

Log in to vote
0
Answered by 1 year ago
Edited 1 year ago

Solution 1

If you want to activate automatically when a Player joins, you can change StarterPlayer.DevComputerCameraMovementMode to Orbital. For mobile devices, you can change StarterPlayer.DevTouchCameraMovementMode to Orbital.

Solution 2

If you want to set the player's camera mode to Orbital when triggered by an event, you can change Player.DevComputerCameraMode to Orbital. For mobile devices, you can change Player.DevTouchCameraMode to Orbital.

For example, you want to set the player's camera mode to Orbital when clicking a button.

-- LocalScript inside the button
local button = script.Parent
local orbital = false

local Players = game:GetService("Players")
local player = Players.LocalPlayer

button.MouseButton1Click:Connect(function() -- when the button is clicked using the left mouse button (common)
    if orbital then -- if camera mode is in orbital
        orbital = false

        player.DevComputerCameraMode = Enum.DevComputerCameraMovementMode.UserChoice -- sets it back to normal (computer devices)
        player.DevTouchCameraMode = Enum.DevTouchCameraMovementMode.UserChoice -- sets it back to normal (mobile devices)
    else
        orbital = true

        player.DevComputerCameraMode = Enum.DevComputerCameraMovementMode.Orbital -- sets it to Orbital (computer devices)
        player.DevTouchCameraMode = Enum.DevTouchCameraMovementMode.Orbital -- sets it to Orbital (mobile devices)
    end
end)
Ad

Answer this question