Getting character's relative velocity, with bodymovers?

I can’t figure out how to obtain the velocity of a character when the character’s velocity is constantly affected by various body movers.

How would I read the velocity of the character?

1 Like

Couldn’t you just read the velocity of the humanoid root part? It can’t be that complicated.

print(character.HumanoidRootPart.Velocity)
1 Like

local wfc = game.WaitForChild
local player = game.Players.LocalPlayer
local char = player.Character
local humanoidrootpart = wfc(char, “HumanoidRootPart”)

local velocity = humanoidrootpart.Velocity --update this in a loop

1 Like

This is my bad for poor communication. I was hoping to find the relative velocity, based of the object and not the world.

I want to check if the player is moving to their right, and at what speed. How do I do this?

The Velocity property is relative (to the base part it’s applied to). You can do base_part.Velocity.Unit if you want a directional vector.

If you want to know just the speed of their character, you can just find the magnitude of their velocity:

print(character.HumanoidRootPart.Velocity.Magnitude)

As for finding the velocity of something relative to another, it depends on what the velocity has to be relative to. If you mean relative to a body mover’s velocity, you can theoretically just subtract the body mover’s velocity component from the character’s velocity.

For example, a velocity relative to a BodyVelocity would be:

HumanoidRootPart.Velocity - BodyVelocity.Velocity

Edit: I reread your post, especially the last part, you can check if a player is moving to their right by requiring the PlayerModule, calling GetControls, and finally calling GetMoveVector on that:

local RunService = game:GetService("RunService")
local player = game:GetService("Players").LocalPlayer
local PlayerModule = require(player:WaitForChild("PlayerScripts"):WaitForChild("PlayerModule"))

local Controls = PlayerModule:GetControls()

local RIGHT = Vector3.new(1,0,0)

player.CharacterAdded:Connect(function(char)
	
	RunService:BindToRenderStep("checkdir",Enum.RenderPriority.Last.Value + 1,function()
		
		if Controls:GetMoveVector() == RIGHT then
			print("right!")
		end
		
	end)
	
end)
3 Likes

Thank you! Before I was trying to get the root’s velocity and somehow create a move vector based on that.

For what I want, this is great! Thanks again!

1 Like