How to make the camera rotate with a moving platform

  1. What is the issue?
    My current method is the only solution I could think of and it doesn’t work.

  2. What solutions have you tried so far?
    Tried looking for similar problems, but I couldn’t even find a singular post like this

-- toFollow is the platform
local newRotation = Vector3.new(math.rad(toFollow.AssemblyAngularVelocity.X), math.rad(toFollow.AssemblyAngularVelocity.Y), math.rad(toFollow.AssemblyAngularVelocity.Z))
		cam.CFrame *= CFrame.Angles(newRotation.X, newRotation.Y, newRotation.Z)

Currently I’m adding the platform’s angularVelocity to the camera’s rotation which isn’t working.

idk exactly what youre saying but i think you want to align the camera with the platform

if the camera is in scriptable mode then you should do
cam.CFrame = cam.CFrame.Position * toFollow.CFrame.Rotation

1 Like

Should’ve specified, but it’s just the regular camera mode.

I believe AssemblyAngularVelocity is measured in Radians Per Second so, this might work!


RunService.Heartbeat:Connect(function(DeltaTime)
local newRotation = Vector3.new(math.rad(toFollow.AssemblyAngularVelocity.X), toFollow.AssemblyAngularVelocity.Y * DeltaTime, math.rad(toFollow.AssemblyAngularVelocity.Z))
cam.CFrame *= CFrame.Angles(newRotation.X, newRotation.Y, newRotation.Z)
end)
1 Like

I took the deltaTime from your script which made it work but also caused a bug where if I would look down or up my camera would rotate too much, if I look perfectly straight ahead then the camera follows the platform just fine.

(The submarine’s AssemblyAngularVelocity is 1 on the Y axis)

Run.Heartbeat:Connect(function(dT)
	if toFollow then
		local newRotation = toFollow.AssemblyAngularVelocity * dT
		cam.CFrame *= CFrame.Angles(newRotation.X, newRotation.Y, newRotation.Z)
	end
end)

I believe it’s because you’re rotating the Camera relative to the Camera CFrame, while the Platform’s Spinning direction is Relative to the World!

Not sure if this will fix it, but try multiplying the CFrame.Angles by the Part.CFrame instead of the opposite

Example (not sure if it’ll work… just try!)

Run.Heartbeat:Connect(function(dT)
	if toFollow then
		local newRotation = toFollow.AssemblyAngularVelocity * dT
		cam.CFrame = CFrame.Angles(newRotation.X, newRotation.Y, newRotation.Z) * Cam.CFrame
	end
end)
1 Like

This works perfectly, tysm!​​​​​​​​​​​​​​​​​​​​​​​​

1 Like