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

How do i edit my Camera Script Without it tilting?

Asked by 3 years ago

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

Log in to vote
1
Answered by 3 years ago

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
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 adieking1 69 — 3y
0
When you change the Vector3 it should be working all well Averted_Vision 177 — 3y
0
Maybe 45 degrees is too much? 45 degrees would make you look up and you wouldn't be able to see your character Averted_Vision 177 — 3y
0
Ok adieking1 69 — 3y
View all comments (6 more)
0
What would you recommend for it to be at 45 degrees from the player? adieking1 69 — 3y
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. Averted_Vision 177 — 3y
0
I feel its too angled up and you cant see much adieking1 69 — 3y
0
If you're trying to make it look directly down just make the X and Z value 0 in your Vector3 Averted_Vision 177 — 3y
0
Ok, Thanks for the help, Its all working fine now. I am accepting this as the answer. adieking1 69 — 3y
0
NP Averted_Vision 177 — 3y
Ad

Answer this question