How to change the camera view of a player, when they walk into a specific area

I’m trying to make a game where the camera changes depending on where your walking, say your walking side to side, (right or to the left) It would look like this, practically a 2D scroller with some depth:
image

I’ve got that part down with a script (the one below doesnt give the exact view my game would have but it works to change the camera angle to the kind of view I would need, I just need to trim it)

But What if the player was walking down into the “Z plane” walking up the screen into an alleyway or something like that, I would like to achieve something like this:
image

As you can see when the character walks “backwards into the map” the camera follows in your average 3rd person view, but when they walk side to side they have that 2d scroller kind of view.

I am trying to be able to transation between these two camera view in different areas, say player is standing in area A they have camera view A, but when they move to area B they have camera view B.

I’ve tried making a transparent block in each area that detects if a player is standing in it then gets the players character, and name then somehow changes the camera angle from there, but I have no idea how to do this.

I know that method is probably extremly inneficient and that why I cant get it to work

After that, you should include more details if you have any. Try to make your topic as descriptive as possible, so that it’s easier for people to help you!

SCRIPT THAT SETS UP THE CAMERA TO HAVE THE "2D SCROLLER VIEW"

local offset = Vector3.new(-5,50,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) 

So now how would i move the camera b (3rd person view) when they go into a specific area then back to camera a when they enter back into a area?

Sorry if i’m asking to much im not that great of a scripter. If you think I should hire somebody let me know please.

please dont sue me nintendo

1 Like

This should put the camera back to normal

local cam = workspace.CurrentCamera

cam.CameraType = Enum.CameraType.Custom
cam.CameraSubject = player.Character.Humanoid
1 Like

But how will i make it only switch to normal when the player touches a specific part?

local cam = workspace.CurrentCamera
local player = game.Players.LocalPlayer

workspace.Area2Part.Touched:Connect(function(hit)
  local hitPlayer = game.Players:GetPlayerFromCharacter(hit.Parent)
  if hitPlayer and hitPlayer == player then
    cam.CameraType = Enum.CameraType.Custom
    cam.CameraSubject = player.Character.Humanoid
  end
end)
2 Likes