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

[Solved] How do i get the camera Orientation to use as the part Orientation?

Asked by
PastDays 108
4 years ago
Edited 4 years ago

I want to to make the players "Marble" face the same way as the Camera but i'm getting nothing, I've tried "Cframe.Angles" as well as "LookVector" but have got nothing to work.

"Y" is the Y angle i need from the camera.

Any help is much appreciated!

while true do wait()
    PlrBall.Orientation = Vector3.new(PlrBall.Orientation.X,"Y", PlrBall.Orientation.Z)
    print(workspace.CurrentCamera.CFrame.LookVector)
end

After more tests and a lot more searching i managed to find a script and slightly change it to get it to work, Hope this at least helps someone else.

local SHIFT = math.rad(90)
local Camera = workspace.CurrentCamera

while wait() do
    local lookVector = Camera.CFrame.lookVector
    local angle = -math.atan2(lookVector.Z, lookVector.X) + SHIFT

    PlrBall.CFrame = CFrame.new(PlrBall.Position) * CFrame.Angles(0, angle, 0)
end

Answer this question