How to Actually Use Roblox's Physics Character Controllers

Thanks for this! Seems to work well.

I believe there is a bug in the Jump action though, specifically regarding the opposite force applied to the floor. There you set the ground sensor’s hit normal as the position, which seems erratic. My suggestion is to change it to the ground sensor’s hit frame position instead, like so:

floor:ApplyImpulseAtPosition(-jumpImpulse, controllerManager.GroundSensor.HitFrame.Position)

Hope this helps and thanks again!

1 Like

why does controllerManager.MovingDirection = Vector3.new(0, 0, 1) work but not

local movingDirection = controllerManager.MovingDirection
movingDirection = Vector3.new(0, 0, 1)
???

Thats cause you’re changing the variable “movingDirection” and not the property “MovingDirection” of the controller

But that = that all I did was made it shorter

the variable only gets the value of the property, so it can’t change the property’s value directly, you’d have to write it like this, which would make it longer than just leaving it how it was.

local movingDirection = controllerManager.MovingDirection
movingDirection = Vector3.new(0, 0, 1)
controllerManager.MovingDirection = movingDirection

well you can not shorten that.

Was wondering if sitting being completely broken was normal, sitting works just fine but getting the player up is quite a process, and after it’s finished the player cant sit on the same seat anymore

1 Like

How would making a footsteps system work in this? i was thinking on getting the movement velocity and the current basepart material that is being stept but idk if it will work correctly

I wouldn’t tie the footsteps to the character controller directly. What I would do is probably go into your walk animation, then add an animation event on each keyframe where the character’s foot touches the ground. Then I’d connect a function to those events that makes a footstep sound/effect every time the event fires

fair enough because i managed to get some code working with the character controller and was awfull… so i will probably do that ty

For some reason this method isnt working for me by now (since im using roblox animate script) though i edited it changed the anims by the ones with the events added the getreachedmarker signal thingy at line 267 but still nothing so idk what to do tbfr

i might replace it by a better one or custom coded one

Hi, this tutorial has been great help for me! but i was wondering if there was a way to completely remove the use of humanoids? as right now i’m not sure how to go about doing so.

Hi, nice tutorial!, one question, what’s the music you used in your movement demo 2 video?, it’s cool

GET ENUF by Hideki Naganuma!

<827393288374282828> (character limit)

Unfortunately there isnt really a good way to replace Humanoids without flaws (one of the biggest, if youre making client-client replicated humanoids, is the server cant physically see where the character is), however these flaws arent too big and the one I mentioned can be fixed using attributes.

I myself have designed a client-client replicated Humanoid alternative which anchors the HRP called FastHumanoid (however it doesnt deal with vertical and horizontal collisions too well because I forgot to give the character a collision hitbox :P), you can check out the source code if you don’t know where to start

Alright, i’ll probably have a look, thanks, i think i might just create a custom character controller so i can have more control over player movement, which is a crucial aspect of my game.

1 Like

im trying to make climbing work like the climbing state in humanoids with the controller manager’s ClimbController and ClimbSensor but i have no idea how to go about making this. I want to understate how did Humanoids detect ladder parts or truffel parts

local function updateControllerManagerSensor()
	local raycastParams = RaycastParams.new()
	raycastParams.FilterDescendantsInstances = {character} -- Character should not be included within things that the raycast can return
	raycastParams.FilterType = Enum.RaycastFilterType.Exclude

	local raycastToGround = workspace:Raycast(humanoidRootPart.Position, Vector3.new(0, -4.5, 0), raycastParams)

	if raycastToGround then -- Character is on the ground, raycast returned something
		groundSensor.SensedPart = raycastToGround.Instance
		groundSensor.HitNormal = raycastToGround.Normal
		groundSensor.HitFrame = CFrame.new(raycastToGround.Position)

		humanoid:ChangeState(Enum.HumanoidStateType.Running) -- Changing humanoid states so we have animations 
		controllerManager.ActiveController = groundController -- Switch the ActiveController to groundController. 
	else -- Character is midair, raycast didn't return anything
		humanoid:ChangeState(Enum.HumanoidStateType.Freefall) 
		controllerManager.ActiveController = airController
	end
	
	-- Define a constant for the multiplier in the raycast direction calculation
	local CLIMB_RAYCAST_MULTIPLIER = 2

	-- Define a function to calculate the raycast direction
	local function getRaycastDirection(humanoidRootPart)
		return (humanoidRootPart.CFrame.LookVector * CLIMB_RAYCAST_MULTIPLIER) + Vector3.new(0, 7.6, 0)
	end
	
	local raycastToLadder = workspace:Raycast(humanoidRootPart.Position, getRaycastDirection(humanoidRootPart), raycastParams)
	
	if raycastToLadder then -- Character is climbing a ladder, raycast returned something
		-- Handle the case where the raycast hit a ladder
		climbSensor.SensedPart = raycastToLadder.Instance
		climbSensor.HitNormal = raycastToLadder.Normal
		climbSensor.HitFrame = CFrame.new(raycastToLadder.Position)
		humanoid:ChangeState(Enum.HumanoidStateType.Climbing)
		controllerManager.ActiveController = climbController
		return
	else -- Character is not climbing
		climbSensor.SensedPart = nil
		controllerManager.ActiveController = groundController
		if humanoid:GetState() ~= Enum.HumanoidStateType.Jumping then
			humanoid:ChangeState(Enum.HumanoidStateType.Running)
		end

	end
end

basicly i want the climbController to do this:

but it does this:

i also want to add siting functionality as well because when the player sits a seat for VehicleSeat they get stuck and can’t jump out.

image

1 Like

How would you increase jump height? BaseMoveSpeed modifies walk speed, but I can’t figure out a way to change the jump height.

You can increase the jump height by increasing the Y value of the jumpImpulse Vector3.