How to find the Rotational Velocity of the Camera?

How would I find the Rotational Velocity of the Camera? For an example, I can find the Rotational Velocity Speed of a Part by doing: Part.RotVelocity.Magnitude, However, RotVelocity isn’t a valid member of the Camera.

2 Likes

I don’t understand what you’re looking for but I think you can try these properties

I’ve tried those but they’ve pretty much returned 0. Also, what I’m looking for is the rotation speed of the camera.

I’m not too experienced with camera’s but try to record the camera’s CFrame.LookVector every RunService.Heartbeat and compare the new LookVector with the old one.

local cam = workspace.CurrentCamera

local rs = game:GetService("RunService")

local lastlvector = cam.CFrame.LookVector
local newlvector

while true do
 oldlvector = cam.CFrame.LookVector
 rs.Heartbeat:wait()
 newlvector = cam.CFrame.LookVector

 --Compare x, y, z from new lookvector with the old one
 --That way you can get the velocity I guess.
end

Typed this in a hurry, don’t have much time to do the compare part but I hope you know what I mean.

Since heartbeats and such can sometimes frame behind a little I recommend using tick() and compare the new tick with the old one and use that so the velocity won’t be a lot different in case a player would have small framedrops or something.

1 Like

You can connect a function to Heartbeat and calculate the difference between the camera’s CFrame on the last step and the current step, then use CFrame:ToEulerAnglesXYZ() to get the angles.

1 Like

You have the right idea, but this is an approximation that is only accurate for small movements of the camera, where the magnitude of (newLookVector-oldLookVector) << 1. If you want the angle the camera has rotated since the last frame, you can do:

local axis, angle = (cameraCFrame * previousCFrame:Inverse()):ToAxisAngle()

The angle value will tell you how much the camera rotated since you set previousCFrame, in radians, which is a discrete sampling of the angular velocity. You probably want to do this on RenderStepped too, so that it’s in sync with the camera CFrame changing (which Heartbeat and Stepped are not).

6 Likes