Requesting assistance fixing ground check for HSM

Hello, I’m working on a third person platformer. The player controller uses a hierarchical state machine taken from this video : https://www.youtube.com/watch?v=OtUKsjPWzO8

Currently, it’s set up so that there is a central state (MBaseGameplayState) which derives into two broader general states (MStateGenAirborne, MStateGenGrounded) which then split into more specific states (walking, falling, jumping etc…) I’ve placed the logic for calculating whether it’s grounded in the central state so that I don’t have to rewrite it for each class. This state also handles movement, and each of the classes that utilize it to modify the movement values to get the movement i’m looking for (drag, speed etc.)

    // MBaseGameplayState

    public override void FixedUpdateState()
    {
        base.FixedUpdateState();

        // grounded check
        if (Physics.Raycast(_mPlayerSM._rb.transform.position, Vector3.down, .6f, LayerMask.GetMask("Ground")) == true && _mPlayerSM._rb.linearVelocity.y <= 0f)
        {
            _grounded = true;
        }
        else
            _grounded = false;

      ...

The issue starts with the jumping state. It adds a vertical force to the player rigidbody and switches to the falling state when the yVel of the rb is <= 0. While it does add the force, it seems that for the duration of the jump, it reads that the velocity is = 0, thus switching to the falling state, which then immediately switches to the idle (grounded) state, because for the duration of the jump it’s also read the raycast as being grounded too.
Even when walking around, the rb velocity reads as 0, even though it’s moving by adding force to it. Strangely, when a line is added to the StateMachine’s update function just to serialize the rb’s velocity, it begins to change the values, but breaks the movement.

I’ve tried adding empty override FixedUpdateStates to each of the related classes (maybe they weren’t being updated/called?) but no no avail. I’ve also tried adding stricter conditionals for switching states, but that doesn’t seem to be the issue.

Very confused as to what the issue could be… Help is appreciated :slight_smile: