Custom character movement ( without Player:Move() )

first, sorry if my english is not really good.
I really dont like the default movement in Roblox, so i decided to create custom movement. I know how to calculate the direction, etc. but i dont know how to actually move the character. i tried using :

  • HumanoidRootPart.Velocity : Glitch a lot with Terrain (sometimes go slow, sometimes fast)

  • BodyForce : (children of HumanoidRootPart) does nothing, exept when i re-enable default movement and jump, i get yeeted to the other side of the map. i guess i shouldnt use that lol

  • BodyVelocity : (children of HumanoidRootPart) half-working, it ignores gravity tho (but i guess i could implement gravity easily, and maybe it would work better ?)

from what i understand, i shouldnt use the other BodyPosition or Player:Move(), and i dont really understand the other BodySomething. I searched on the devforums for hours and found nothing.
Is there something i forgot ? and how would you do it ?

I’ll be happy to give more info if you need.

if someone answers quickly, i will not answer right away since its 2am for me :stuck_out_tongue:

3 Likes

Here’s something I put together real quick for you :wink:
script.Parent.Touched:Connect(function(hit)
if hit.Parent:FindFirstChild(“Humanoid”) then — checks if the thing that touched has a humanoid to make sure it’s an actual player
hit.Parent.HumanoidRootPart.CFrame = CFrame.new(game.Workspace.TeleportPart.Position)

Sorry if the code is wrong just tell me if it is writing Th is on a phone rn :sweat_smile:

Here’s also a tutorial on CFrame which is what I used to move the player https://m.youtube.com/watch?v=gUGJkhhtfUo

1 Like

In order to let gravity act on the character with BodyVelocity, you need to set the Y-axis of the BodyVelocity MaxForce to 0.

BodyForce probably does nothing as you are exerting too little force. You need to account for the mass.

The way you’d do it is you get the mass of the model, which after that you then do MovementVelocity * Mass. Here’s a function to get the model mass:

local function GetModelMass(Model)
	local Mass = 0

	local Descendants = Model:GetDescendants()
	for _, Descendant in pairs(Descendants) do
		if Descendant:IsA("BasePart") and not Descendant.Massless then
			Mass += Descendant:GetMass()
		end
	end

	return Mass
end
4 Likes

I did some testing and BodyForce cant be an option since its slowly going to the target speed, and i want the speed to be constant. For BodyVelocity, if i move on Terrain, its either going very slowly or way too fast. (if i set the MaxForce to (13000,0,13000) its very slow, but when i set it to (14000,0,14000) its going way too fast.)

for BodyForce and BodyVelocity, every frame i calculate the direction relative to the camera/the keys pressed. gives me a Unit Vector that i multiply by the speed (and the mass for the BodyForce) then overwrite the Velocity/Force property. Am i doing something wrong ? and is it even possible to do what i want ?

i also tried :

  • Negative MaxForce.Y
  • using a BodyGyro
  • changing values like P for BodyVelocity, D, P and MaxTorque for BodyGyro

nothing worked

btw my game is in first person, and the BodyVelocity/BodyForce is a children of HumanoidRootPart. The mass i got was around 15, and my speed variable was always > 1000

Okay, scrap using BodyForce then.

BodyVelocity should work perfectly, Vector3.new(1000000, 0, 1000000) should work fine for the MaxForce.

Then you simply set BodyVelocity.Velocity your unit vector multiplied by the speed. This should work fine for you.
The P property no longer does anything in BodyVelocity, as stated in the wiki page:

Note: This property is ignored if PGS is enabled via Workspace.PGSPhysicsSolverEnabled, which is enabled by default.

1 Like

Works exactly like i wanted, thank you so much! i guess my MaxForce was way too low :stuck_out_tongue: