Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

How do i edit my Camera Script Without it tilting?

I Am trying to make a top down camera script. So I Asked a question earlier today asking why my script wasn't working, I got a reply with an edited one that did work, however when i try to make a small adjustment to the distance from the player or the angle the camera is facing the player at, it makes the camera all wonky and It doesn't work properly then. Script:

game:GetService("ControllerService"):ClearAllChildren()

repeat wait() until game.Players.LocalPlayer.Character
local char = game.Players.LocalPlayer.Character
local cam = game.Workspace.CurrentCamera

cam.CameraType = Enum.CameraType.Scriptable
cam.FieldOfView = 70

spawn(function()
    while true do
        game:GetService("RunService").RenderStepped:wait()
        local pose = char.HumanoidRootPart.Position + Vector3.new(5, 10, -5)
        local lookAt = char.HumanoidRootPart.Position
        cam.CFrame = CFrame.new(pose , lookAt) * CFrame.Angles(0,0,0)-- Please note that the Angles part is for after the script works so I can adjust it then.
    end
end)

I want an angle at 45 degrees so for that the:

CFrame.Angles(0,0,0) -- line 13

Would need to be:

CFrame.Angles(45,0,0) -- line 13

but when i do that, it makes it all wonky, its the same if i want to make it 15 studs away from the character here:

Vector3.new(5, 10, -5) -- line 11

Any fixes are welcome. Please ask for any more information, and no, there is not a error message.

1 answer

✓ Accepted answer

CFrames.Angles uses radians, so to convert degrees into radians use math.rad EX:

CFrame.Angles(math.rad(45),0,0) -- converted degrees into radians

10 comments

0

I know why it makes it weird but i dont know how to fix it. its because i am Xing it together and that has some weird effects

0

When you change the Vector3 it should be working all well

0

Maybe 45 degrees is too much? 45 degrees would make you look up and you wouldn't be able to see your character

0

Ok

0

What would you recommend for it to be at 45 degrees from the player?

0

15 Degrees maybe? What exactly are you trying to do? The normal script without changing it works fine for a top down view game.

0

I feel its too angled up and you cant see much

0

If you're trying to make it look directly down just make the X and Z value 0 in your Vector3

0

Ok, Thanks for the help, Its all working fine now. I am accepting this as the answer.

0

NP

This discussion is preserved as it was. New answers, comments, and votes are closed.