How to Actually Use Roblox's Physics Character Controllers

In this part of the code:

local function doJump(actionName, inputState)
    if actionName == "JUMP_ACTION" and inputState == Enum.UserInputState.Begin and humanoid:GetState() ~= Enum.HumanoidStateType.Ragdoll then
        local jumpImpulse = Vector3.new(0, 750, 0) -- Y is jump power. Change as you see fit.  

        controllerManager.RootPart:ApplyImpulse(jumpImpulse)
        
        humanoid:ChangeState(Enum.HumanoidStateType.Jumping) 
        
        local floor = controllerManager.GroundSensor.SensedPart
        if floor then -- Character's on the floor?  
            floor:ApplyImpulseAtPosition(-jumpImpulse, controllerManager.GroundSensor.HitNormal) -- Equal and opposite force  
        end
    end
end

The relevant part would be:

local jumpImpulse = Vector3.new(0, 750, 0)

This is where the jump force is being applied.

How about swimming? how do i activate swimming functionality

Hello, good tutorial.

Have you made any reliable methods for the “Landed” HumanoidStateType to work when character actually has landed, if yes would you mind sharing?

1 Like

Hello! When I was coding landing animations for my game, I used Humanoid.StateChanged. In particular, I checked for when the oldState was Freefall and the newState was Running. Then I simply changed the state to Landed.

Wonderful tutorial! I haven’t found alot like this in a while. I was just wondering:

Somebody already said how to detect player deaths and such previously on this thread. How can I respawn the player and stop the player from moving/controlling the character after death?

Made a full game which was only possible if this topic existed.

1 Like

You can do that by using the asset in roblox’s topic.

Now this is crazy impressive! Glad this topic was helpful

1 Like