Crouch ambiguity when swimming.

Discuss coding questions, pull requests, and implementation details.
Post Reply
User avatar
MeteoricDragon
Posts: 141
Joined: Mon Feb 12, 2018 8:23 pm

Crouch ambiguity when swimming.

Post 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?

User avatar
Interkarma
Posts: 7236
Joined: Sun Mar 22, 2015 1:51 am

Re: Crouch ambiguity when swimming.

Post 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.

User avatar
MeteoricDragon
Posts: 141
Joined: Mon Feb 12, 2018 8:23 pm

Re: Crouch ambiguity when swimming.

Post by MeteoricDragon »

In my PR. Allofich said there's a spot that requires crouching in castle wayrest. So... I guess that answers my question.

User avatar
MeteoricDragon
Posts: 141
Joined: Mon Feb 12, 2018 8:23 pm

Re: Crouch ambiguity when swimming.

Post by MeteoricDragon »

When the player is touching the ground when swimming, the grounded variable isn't true, how curious...

User avatar
Interkarma
Posts: 7236
Joined: Sun Mar 22, 2015 1:51 am

Re: Crouch ambiguity when swimming.

Post 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..

User avatar
MeteoricDragon
Posts: 141
Joined: Mon Feb 12, 2018 8:23 pm

Re: Crouch ambiguity when swimming.

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

User avatar
MeteoricDragon
Posts: 141
Joined: Mon Feb 12, 2018 8:23 pm

Re: Crouch ambiguity when swimming.

Post 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.

Post Reply