How I can solve this?

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;
            }
        }

    }
    }

-- 
Audiogames-reflector mailing list
Audiogames-reflector@sabahattin-gucukoglu.com
https://sabahattin-gucukoglu.com/cgi-bin/mailman/listinfo/audiogames-reflector
  • ... AudioGames . net Forum — Developers room : alisson via Audiogames-reflector
    • ... AudioGames . net Forum — Developers room : ambro86 via Audiogames-reflector
    • ... AudioGames . net Forum — Developers room : alisson via Audiogames-reflector

Reply via email to