Help needed with CharacterManager

I want to create a CharacterManager that emulates the behavior of Humanoid as closely as I can get it to be. Right now, it is in very early development.
Sometimes, the controller randomly decides to act really buggy for some reason? I’m not too sure why. It randomly stops moving and can’t walk up two stud parts

When it happens normally:


Very buggy behavior that happens on some occasions:

The rig is there as a demonstration of how the humanoid works compared to my controller.
dont ask me why i added randomly changing colors to the video. i thought it would be cool to code it.

Server authority is not enabled. The IAS PlayerModule is enabled, but that shouldn’t change anything.

The code

This depends on a Rig with a humanoid existing within the workspace when the game starts running.

This is in StarterCharacterScripts and runs on the client.

--!strict
const RunService = game:GetService("RunService")

local character = script.Parent
if not character or not character:IsA("Model") then
	return
end

local althumanoid = workspace.Rig.Humanoid

local humanoid = character:WaitForChild("Humanoid") :: Humanoid
humanoid.EvaluateStateMachine = false

local rootPart = humanoid.RootPart or character:WaitForChild("HumanoidRootPart") :: BasePart

-- Create the thing
local controller = Instance.new("ControllerManager")
controller.BaseTurnSpeed = 12
controller.Parent = script.Parent
controller.RootPart = rootPart

-- Create sensors
local groundSensor = Instance.new("ControllerPartSensor")
groundSensor.Parent = rootPart
groundSensor.Name = "GroundSensor"
groundSensor.SearchDistance = 3.3
groundSensor.SensorMode = Enum.SensorMode.Floor
controller.GroundSensor = groundSensor

local climbSensor = Instance.new("ControllerPartSensor")
climbSensor.Parent = rootPart
climbSensor.Name = "ClimbSensor"
climbSensor.SearchDistance = 1
climbSensor.SensorMode = Enum.SensorMode.Ladder
controller.ClimbSensor = climbSensor

-- Initialize sub-controllers
local airController = Instance.new("AirController")
airController.Parent = controller
local climbController = Instance.new("ClimbController")
climbController.Parent = controller
local groundController = Instance.new("GroundController")
groundController.Parent = controller
groundController.GroundOffset = 2
local swimController = Instance.new("SwimController")
swimController.Parent = controller
controller.ActiveController = groundController

-- RunService loop
RunService:BindToRenderStep("MyController_Movement", Enum.RenderPriority.Character.Value + 1, function()
	local movementVector = humanoid.MoveDirection
	althumanoid:Move(movementVector) -- Moves the Rig
	controller.MovingDirection = movementVector
	if movementVector.Magnitude >= .1 then
		controller.FacingDirection = movementVector
	end
end)

Any help would be appreciated.

It looks like this was due to arm and leg collisions not becoming CanCollide false sometimes. I added code to ensure the arms and legs are CanCollide false and this is probably the solution.

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.