Jump w/ Roblox's character physics controller only working on slopes

Title. I’m experimenting with roblox’s new character physics controllers, and I’m using their default statemachine script. However, the jump they provide only activates on spawn and on slopes.

Stuff I tried:

  • Shapecasting under the player instead of using Roblox’s isControllerActive function
  • Printing every time I press space. For some reason, this works if you just take out all of the jumping logic but using the actual jumping code it only prints on a jump
  • Using a normal Vector3 instead of the JumpImpulse attribute. No dice
  • Messing with the groundsensor’s sense distance

Here is a clip of it in action

External Media

And here is the section of code

local function groundCheck()
	local params = RaycastParams.new()
	params.FilterDescendantsInstances = {character}
	params.FilterType = Enum.RaycastFilterType.Exclude
	
	local groundResult = workspace:Shapecast(ControllerManager.RootPart, Vector3.new(0, -5, 0), params)
	if groundResult then 
		return groundResult
	end
end

-- Manage attribute for configuring Jump power
ControllerManager:SetAttribute("JumpImpulse", Vector3.new(0,750,0))

-- Jump input
local function doJump(actionName, inputState, inputObject)
	print("Jump")
	local groundResult = groundCheck()
	
	if actionName == "Jump" and inputState == Enum.UserInputState.Begin and isControllerActive(ControllerManager.GroundController) and groundResult.Material ~= Enum.Material.Air then
		local jumpImpulse = ControllerManager:GetAttribute("JumpImpulse")
		ControllerManager.RootPart:ApplyImpulse(jumpImpulse)

		character.Humanoid:ChangeState(Enum.HumanoidStateType.Jumping)
		ControllerManager.ActiveController = ControllerManager.AirController

		-- floor receives equal and opposite force
		local floor = ControllerManager.GroundSensor.SensedPart
		if floor then
			floor:ApplyImpulseAtPosition(-jumpImpulse, ControllerManager.GroundSensor.HitFrame.Position)
		end
	end
end

ContextActionService:BindAction("Jump", doJump, true, Enum.KeyCode.Space)

Any help is appreciated. Thanks!

1 Like
local ContextActionService = game:GetService("ContextActionService")
local ControllerManager = script.Parent:WaitForChild("ControllerManager")
local character = script.Parent

local function groundCheck()
    local params = RaycastParams.new()
    params.FilterDescendantsInstances = {character}
    params.FilterType = Enum.RaycastFilterType.Exclude
    
    local rayOrigin = ControllerManager.RootPart.Position
    local rayDirection = Vector3.new(0, -5, 0)
    
    local rayResult = workspace:Raycast(rayOrigin, rayDirection, params)
    if rayResult then 
        return rayResult
    end
end

-- Manage attribute for configuring Jump power
ControllerManager:SetAttribute("JumpImpulse", Vector3.new(0, 750, 0))

-- Jump input
local function doJump(actionName, inputState, inputObject)
    print("Jump function called")
    local groundResult = groundCheck()
    
    if actionName == "Jump" and inputState == Enum.UserInputState.Begin then
        print("Jump input detected")
        
        if isControllerActive(ControllerManager.GroundController) and groundResult and groundResult.Material ~= Enum.Material.Air then
            print("Ground detected, performing jump")
            
            local jumpImpulse = ControllerManager:GetAttribute("JumpImpulse")
            ControllerManager.RootPart:ApplyImpulse(jumpImpulse)

            character.Humanoid:ChangeState(Enum.HumanoidStateType.Jumping)
            ControllerManager.ActiveController = ControllerManager.AirController

            -- floor receives equal and opposite force
            local floor = ControllerManager.GroundSensor.SensedPart
            if floor then
                floor:ApplyImpulseAtPosition(-jumpImpulse, ControllerManager.GroundSensor.HitFrame.Position)
            end
        else
            print("Jump conditions not met")
        end
    end
end

ContextActionService:BindAction("Jump", doJump, true, Enum.KeyCode.Space)

Untitled - Clipped with Medal.tv No dice. Curiously, not even the prints get outputted when being input on the ground.

Update: no solution yet. For some reason, it allows me to jump whenever I want if the groundcontroller’s GroundOffset is zero.

Any help is appreciated. I’ve been stuck on this ever since I opened the topic.

a little late here, but for future reference: Make sure the ground sensor’s search distance is greater than the controller’s GroundOffset, otherwise it will not work