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

Making a part have the same rotation as the camera?

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

✓ Accepted answer

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

Camera.CoordinateFrame is a CFrame value, just like BodyGyro.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 comment

1

I forgot you could put limitations on the turning speeds on each axiz s .-.

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