Changing My Camera From 3D To 2D When Playing A Level

  1. What do you want to achieve? Converting the player’s camera to 2D from 3D when they join a level in my game.

  2. What is the issue? The camera isn’t changing from 3D to 2D when they join a level.

  3. What solutions have you tried so far? I Have Followed The Basic Camera Manipulation Rule Which Is to Put The CameraScript In StarterPack Or StarterPlayerScripts. I Made The Script Disable And Only Make It Enable When The Player Joins A Level.

  4. Other -: When i try using the script as like when the player joins the game their camera instantly changes to 2D but when i want it to become 2D at a certain time (when they join a level) it doesn’t change. There Are No Errors In The Output.

    Hope Someone Helps :pensive:

1 Like

Change the camera type to scriptable, that way you could script the new position of the camera and the camera will follow.

1 Like

I’m Using Attach Instead Of Scriptable Because The Camera Needs To Follow The Player Smoothly And It Only Works When It’s Attached.

You could just use tween service for that.

How Can You Use Tween Service For Camera Manipulation .-.

You can tween the camera’s CFrame property.

The Problem is Not With The Camera Script Or Anything The Script Is Working Fine. The Problem Is That It’s Not Working When I Want It To Basically Like The Code Doesn’t Run Even if I Order It To.

I’ll need to see the script to be able to help.

Check out AlvinBlox’s tutorial. He did a video of it.

local player = game.Players.LocalPlayer

local camera = workspace.CurrentCamera

local character = player.Character or player.CharacterAdded:Wait()

player.Character:WaitForChild("Head")

camera.CameraSubject = player.Character.Head

camera.CameraType = Enum.CameraType.Attach

camera.FieldOfView = 120

game:GetService('RunService').Stepped:Connect(function()

camera.CFrame = CFrame.new(player.Character.Head.Position) * CFrame.new(0,0,10)

end)

https://gyazo.com/c4d8799a7b71c0f06f42a106590b554a

This Link Is The Video Of How It Works.

Everything Basic Nothing Complicated.

I Also Have A 2D Character Controller Which Makes The Character Move With Only A And D Key But It Has No Problem This Script Is The Script Which Locks The Camera To 2D.

It looks like it works? If you want it to be smoother I recommend you instead of:

camera.CFrame = CFrame.new(player.Character.Head.Position) * CFrame.new(0,0,10)

you do:

game:GetService("TweenServce"):Create(camera,TweenInfo.new(0.05),{CFrame = CFrame.new(player.Character.Head.Position) * CFrame.new(0,0,10)}:Play()

bro i did say there’s Nothing WITH Tweening IM saying That the script is not running the code.

I’m confused, the code seems to be running, is the code not supossed to attach your camera to the player’s head?

local player = game.Players.LocalPlayer

local camera = workspace.CurrentCamera

local character = player.Character or player.CharacterAdded:Wait()

player.Character:WaitForChild("Head")

camera.CameraSubject = player.Character.Head

camera.CameraType = Enum.CameraType.Attach

camera.FieldOfView = 120

    game:GetService('RunService').Stepped:Connect(function()
    	print 'hello'
    	camera.CFrame = CFrame.new(player.Character.Head.Position) * CFrame.new(0,0,10)
    	
    end)

It is running for reference I put this script in StarterPlayerScripts.
https://gyazo.com/270f30b7872c22f0990c131f6aeff781

when they enter the level you could change the camera type to scriptable and then make a loop changing the cframe of the camera to the humanoid root part’s cframe with an offset until the level is finished