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

Making a part have the same rotation as the camera?

Asked by 9 years ago

I have a Part that has a BodyGyro in it. The Part is supposed to follow the orientation of the CurrentCamera. Here is the script to do so:

script.Parent.counter.Force = Vector3.new(0,196.2,0)*script.Parent:GetMass()--antigrav, ignore
local prev
while true do
    local vec = workspace.CurrentCamera.CoordinateFrame.lookVector
    script.Parent.BodyGyro.CFrame = CFrame.Angles(vec.X,vec.Y,vec.Z)
    if vec ~= prev then
    print(script.Parent.Rotation)
    prev = vec
    end
    wait(0.1)
end

The Part moves, but does not follow the CoordinateFrame of the CurrentCamera. Could someone explain why?

1 answer

Log in to vote
1
Answered by 9 years ago

I feel like you're thinking a bit too hard about this problem.

Camera.CoordinateFrame is a CFrame value, just likeBodyGyro.CFrame is a CFrame value.

All you have to do is set BodyGyro.CFrame to Camera.CoordinateFrame

script.Parent.BodyGyro.CFrame = game.Workspace.CurrentCamera.CoordinateFrame
1
I forgot you could put limitations on the turning speeds on each axiz s .-. TheDogetor 35 — 9y
Ad

Answer this question