Page 1 of 1

Crouch ambiguity when swimming.

Posted: Tue Aug 21, 2018 12:27 am
by MeteoricDragon
Right now, crouching makes you swim downward and toggle crouch at the same time if you are swimming, it does this each and every time you press crouch. How do you want this ambiguity dealt with?

should the player not be allowed to crouch when swimming, and automatically stand if entering dungeon water?

Should the player only toggle crouch if the player is already on the ground while swimming, and be disallowed from crouching if not grounded and swimming?

Re: Crouch ambiguity when swimming.

Posted: Tue Aug 21, 2018 12:58 am
by Interkarma
MeteoricDragon wrote: Tue Aug 21, 2018 12:27 am should the player not be allowed to crouch when swimming, and automatically stand if entering dungeon water?
I lean more towards this option. I'm also interested in feedback from others if anyone sees an issue with this.

Re: Crouch ambiguity when swimming.

Posted: Tue Aug 21, 2018 5:36 pm
by MeteoricDragon
In my PR. Allofich said there's a spot that requires crouching in castle wayrest. So... I guess that answers my question.

Re: Crouch ambiguity when swimming.

Posted: Tue Aug 21, 2018 9:07 pm
by MeteoricDragon
When the player is touching the ground when swimming, the grounded variable isn't true, how curious...

Re: Crouch ambiguity when swimming.

Posted: Tue Aug 21, 2018 9:21 pm
by Interkarma
I believe this is a limitation of the character motor in Unity. It can also be an issue when levitating over a moving platform, the platform will simply pass through player. I don't have a good solution for this at this time.

Maybe best answer for now is just to allow crouch toggle in water and add this as a bug for later review. Alternatively we could decouple crouch from "float down" input so crouch is just crouch..

Re: Crouch ambiguity when swimming.

Posted: Tue Aug 21, 2018 9:35 pm
by MeteoricDragon
Interkarma wrote: Tue Aug 21, 2018 9:21 pm I believe this is a limitation of the character motor in Unity. It can also be an issue when levitating over a moving platform, the platform will simply pass through player. I don't have a good solution for this at this time.

Maybe best answer for now is just to allow crouch toggle in water and add this as a bug for later review. Alternatively we could decouple crouch from "float down" input so crouch is just crouch..
I think i just figured out a solution. I'm going to go test it. I check the collision flags on levitateMotor in the heightchanger class on whether the player can toggle crouch or not.

Code: Select all

             else if (!playerMotor.IsRiding && !onWater &&
                (!levitateMotor.IsSwimming || !levitateMotor.IsLevitating || levitateMotor.CollisionFlags == CollisionFlags.Below))
            {
                // Toggle crouching
                if (InputManager.Instance.ActionComplete(InputManager.Actions.Crouch))
                {
                    if (playerMotor.IsCrouching)
                        heightAction = HeightChangeAction.DoStanding;
                    else
                        heightAction = HeightChangeAction.DoCrouching;
                }
            }   

Re: Crouch ambiguity when swimming.

Posted: Tue Aug 21, 2018 9:58 pm
by MeteoricDragon
The code i posted above didn't work, and I think I have another solution. Involves testing to see if the player has changed YPosition after pressing crouch to descend. If no descent, and is swimming, crouch.