Get a players Velocity using Only CFrame

I would like to know if it is possible to get a players Velocity by not using Humanoid or .Velocity, like using only CFrame and Position

You can use the difference of two vectors over a delta of time. Other than that only 1 CFrame/Position won’t give velocity. Though the delta time would have to be very short for it to be decently accurate. Thus why just getting the velocity from a basepart property is easier.

1 Like

Because on the client all other players velocities will be zero but I need to still somehow get them

Why do you even need to get that?

Predicting where the player will be in n seconds

Does it return 0 as the assemblylinearvelocity.Magnitude of the humanoidrootpart on the server when moving?

I do not have HumanoidRootPart’s

What Velocity are you trying to measure exactly?

BasePart.Velocity but instead getting it through another means like CFrame

Well, Velocity is change in position every second (I think). CFrame has a Position and an Orientation. Therefore you can simply use the position instead.

The formula would go something like this

local PreviousPosition = BasePart.Position
-- Here is where you either wait a frame you can wait as much or as little time. However if a BasePart is Accelerating then longer wait times will be more innacurate.
-- wait(1) You could use this instead of Stepped
local RunTime, DeltaTime = RunService.Stepped:Wait() -- I am waiting a frame
local CurrentPosition = BasePart.Position

local Velocity = (CurrentPosition - PreviousPosition) / DeltaTime

This is the formula D/T = S
D = Distance
T = Time
S = Speed / Velocity

I recommend you use BasePart.LinearVelocity instead as it is much easier.

2 Likes

so for every player that is not localplayer and has a head I should loop through them everyframe get their velocities put them in a table?

1 Like