2020-02-06 14:47:04

Hi. I'm giving more mechanics to the player in a game i'm making, and one of that mechanics is crouch. but... I'm failing miserably.
So I'll try to explain what is happen. I want the player to make the crouch movement smoothly, and I have a code for that. It works more or less, but the transition is not automaticly as I espected it to be. Besides that, when the player is completely crouched, the code for the player stand up is not working. If someone can help me a bit, I will be very grateful. Below is the code for reference.
In the actions update i have this.
if(Input.WasKeyPressed(Keys.K))
            {
                playerState = state.IsCrouching;
            }

//Then is the crouch logic, more or less
public void checkcrouch() //this metod go in the Player update
        {
            switch (playerState)
            {
                case state.IsCrouching:
                    crouching();
                    break;
                case state.IsStanding:
                    standing();
                    break;
                case state.IsCrouch:
                    crouched();
                    break;
            }
        }

        public void standing()
        {
            if(currentsice<sice)
            {
                currentsice += 0.1f;
            }
            else
            {
                playerState = state.IsStand;
            }
        }

        public void crouching()
        {
            if(currentsice>crouchsice)
            {
                currentsice += -0.1f;
            }
            else
            {
                playerState = state.IsCrouch;
            }
        }

        public void crouched()
        {
            if(Input.WasKeyPressed(Keys.K))
            {
                playerState = state.IsStanding;
            }
        }

    }
    }

Sorry for my english

Thumbs up

2020-02-06 17:19:11

Hi Alisson, what programming language did you use? Java? I ask you this because I also know Java and I would like to ask you if you used any engine to program the game.

Thumbs up

2020-02-06 18:46:07

I @ambro86. I'm using c# plus monogame, is a great  framework.

Sorry for my english

Thumbs up