need help to make a character running

i need help to make my character running.
This is not the whole script.
if i press input button run the character must go to run state.
but the character didn’t do it.

public void DetermineCurrentMoveDirection()
    {
        var forward = false;
        var backward = false;
        var left = false;
        var right = false;
	var Run = false;

        if (Input.GetButtonDown("Run"))
	    Run = true;
	if (TP_Motor.Instance.MoveVector.z > 0)
            forward = true;
        if (TP_Motor.Instance.MoveVector.z < 0)
            backward = true;
        if (TP_Motor.Instance.MoveVector.x > 0)
            right = true;
        if (TP_Motor.Instance.MoveVector.x < 0)
            left = true;
	
										
	if (forward)
        {
            if (left)
                MoveDirection = Direction.LeftForward;
            else if (right)
                MoveDirection = Direction.RightForward;
	    else
                MoveDirection = Direction.Forward;
			
	}
        else if (backward)
        {
            if (left)
                MoveDirection = Direction.LeftBackward;
            else if (right)
                MoveDirection = Direction.RightBackward;
            else
                MoveDirection = Direction.Backward;
        }
	else if (Run)
	{
		MoveDirection = Direction.Run;
		forward = false;
		Run = true;
	}
        else if (left)
        {
            MoveDirection = Direction.Left;
        }
        else if (right)
        {
            MoveDirection = Direction.Right;
        }
        else
        {
            MoveDirection = Direction.Stationary;
        }
    }

and I would really like that the character a number of seconds can run and that it then need to recharge a few seconds.
I hope someone could help me also with this.

Have you checked that Run is actually set to true? (print it)

how can i check that?

Try this:

    if (Input.GetButtonDown("Run"))
        Run = true;
    print("It is " + Run + " that I should run!");

I see nothing in the console. so I think run did not go to true.

if i do this code:

if      (Input.GetButtonDown("Run"))
        Run = true;
        Debug.Log("running is true: " + State.ToString());

i see for 1 second running, and then it go to the idle stand or walk.
if i press input run again, there did not come running again.

What you can do is put print statements in different places of your code so that you know what’s executing and what’s not.

i have this for my characterstate
if i walk forward i see in the console CharacterState.WalkForward
that works.
but if i press the input button Run.
i see CharacterState.Running for 1 second.
it doesn’t matter if i hold that key down or not.
and if i press that button again, there did not come CharacterSate.Running again.
(all CharacterSatements work but not the running state

void ProcessCurrentState()
    {
        switch (State)
        {
            case CharacterState.Idle:
                Idle();
                break;
            case CharacterState.WalkForward:
                WalkForward();
                break;
            case CharacterState.WalkBackwards:
                WalkBackwards();
                break;
            case CharacterState.StrafingLeft:
                StrafingLeft();
                break;
            case CharacterState.StrafingRight:
                StrafingRight();
                break;
			case CharacterState.Running:
				Running();
				break;
            case CharacterState.Jumping:
                Jumping();
                break;
            case CharacterState.Falling:
                Falling();
                break;
            case CharacterState.Landing:
                Landing();
                break;
            case CharacterState.Climbing:
                Climbing();
                break;
            case CharacterState.Sliding:
                Sliding();
                break;
            case CharacterState.Using:
                Using();
                break;
            case CharacterState.Dead:
                Dead();
                break;
            case CharacterState.ActionLocked:
                break;
        }
    }

You need to go back to first principles and put in print statements around the area of code you feel is giving you the error. Once you do that you’ll be able to narrow the problem down. Is that all the code there is for movement? Where is the code for WalkForward?

ditto. The code for Running() might be even more telling.