Making player Height into Yes or No Statement

Need help with my crouching and sprinting system.
I have it set up to where I will not Sprint while crouching which I want, but I also have it where if an object is above a players head they will not stand up. This means they no longer need to hold the “Crouch” input allowing them to sprint again. I was wondering if there is anyway I could use my player height instead of the input for my Bools.

Post code, please.

image

Sprinting


Crouching Part 1

Crouching Part 2. I couldnt throw these all in one reply since im a new account or smth.

I can barely read your images.

You posted in the CPP board, so I thought you wanted a C++ solution. I avoid blueprints like the plague. One of the main reasons is they quickly become a mess if you want to do anything complicated.

If you want to be pointed in the right direction, you need a function called CanSprint that determines if a player is allowed to sprint or not. Then that function is the single source of truth for whether you can sprint or not.

Here is some pseudocode that explains what I mean:

bool CanSprint()
{
    // Check if the player is crouching
    if (isCrouching())
    {
        // If crouching, return false to prevent sprinting
        return false;
    }
    
    // Check if there's an obstacle above the player's head
    if (IsObstacleAboveHead())
    {
        // If obstacle above head, return false to prevent standing up and sprinting
        return false;
    }

    // Check if the sprint input button is pressed
    if (IsSprintButtonPressed())
    {
        // If sprint button is pressed and no obstacle above head, allow sprinting
        return true;
    }

    // If none of the above conditions are met, do not allow sprinting
    return false;
}