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

How do I SET the rotation of the currentcamera?

Asked by 4 years ago

Lets say I have code like this :

repeat wait() until game.Players.LocalPlayer.Character

local Player = game.Players.LocalPlayer
local camera = workspace.CurrentCamera

while wait() do
    camera.CFrame = camera.CFrame * CFrame.Angles(0,math.rad(45),0)
end

The problem with this is that the camera just keeps rotating. I want to find a way to be able to SET the rotation of the camera.

This doesn't work either :

while wait() do
    camera.CFrame = CFrame.Angles(0,math.rad(45),0)
end

I'm not sure how to set the rotation itself. to make it point to a specific degree while it's in a loop. Does anyone know how to SET it in a loop?

1 answer

Log in to vote
0
Answered by 4 years ago

I'm not to sure on what you're trying to achieve, if you are trying to rotate the camera so its constantly looking at a part, refer to:

Setup: Place a part in which you want the camera to constantly look at

while wait() do
local camera = workspace.CurrentCamera
local pos = CFrame.new(x,y,z) --The position of the part
local lookAt = part.Position --What position/part its looking at
pos = Vector3.new(pos.X, pos.Y, pos.Z)


camera.CFrame  = CFrame.new(pos, lookat).
end

This will allow you to alter the degree in which it looks at so you don't have to manually alter the degree in the script.

0
the pos variable is the position of the camera my bad ^ evilninja77 20 — 4y
0
Hi, I'm sorry but this isn't what I'm trying to do. I am trying to set, rather than repetitively adding the radiants to the camera. Just try the script that I've posted and you'll see that it just keeps adding up. I'm trying to SET (not add) the camera rotation to point to a specific radiant. awesomecaysson 0 — 4y
0
and also, even if I place parts in which I want to make the camera to point at, I'm trying to make multiple so I can't just do that. awesomecaysson 0 — 4y
0
Set a variable of the degree outside the wait() loop then set the rotation on the camera therefore the camera wont continuously change rotation evilninja77 20 — 4y
View all comments (2 more)
0
yeah that's what I did. There is a variable with the degree outside of the loop. But I'm not sure how to set the rotation if i put it in the loop due to the fact that the degrees in that variable constantly changes so the camera has to keep pointing to those degrees. awesomecaysson 0 — 4y
0
Why the degrees wont change unless you're multiplying the cframe by another, otherwise the radians are fixed. evilninja77 20 — 4y
Ad

Answer this question