Phazorknight / Cogito

Immersive Sim Template Project for GODOT 4
MIT License
902 stars 101 forks source link

Improve in-air behavior for crouch and slide jumps #82

Closed FailSpy closed 7 months ago

FailSpy commented 7 months ago

This is a little prescriptive to what I found "feels right", but in response to #79, I've modified how crouch and slide jumps feel and look.

In #79, @ksjfhor found that un-crouching mid-air would look as though there's a sudden upwards velocity to exactly where you'd expect the jump to be if you had done it standing. It is merely a visual effect from the camera moving from the crouched height to the standing height, the jump is functionally exactly the same. The only thing that changes is the camera height, and the collision to make collisions consistent with what the player is seeing.

I personally find this behavior makes for consistent functionality both as a player and as a dev trying to find the right game feel. When crouch jumping, the characters feet comes off the ground by exactly the same amount whether crouched or standing.

To address the visual jitter, I made it so you can't change your standing/crouching state visually whilst jumping. This feels a little prescriptivist, but I think is the neatest solution for right now with minimal compromise in terms of actual game functionality and feel. If you're making a parkour game however, you may find you need to alter this behavior with a custom solution to resolve this, but that likely would've been the case anyways.

I also changed the in-air behavior. If you're crouched and in-air, you will consistently have the crouch movement speed, unless you're jumping from a slide. If you're slide jumping, your character will largely be registered as being in the "standing" state, which also includes having the camera in the standing state.

I've added 2 parameters for devs to be able to dial in their game feel: CROUCH_JUMP_VELOCITY - what force your jump should have if crouch jumping SLIDE_JUMP_MOD - modifier to how strong your jump is coming from a slide

Phazorknight commented 7 months ago

I saw they were still recent commits, so I held off. Let me know when I can review.

FailSpy commented 7 months ago

You're all set to review actually @Phazorknight, just wrapped it up. The more recent commits were minor addendums to the overall PR.

Phazorknight commented 7 months ago

Gave this a test and noticed that when I sprint > crouch > jump, I leap higher than with a regular jump (see video). I'd qualify this as unexpected behavior.

https://github.com/Phazorknight/Cogito/assets/70389309/53acb499-f35a-435e-8c9f-27c911f90ac3

FailSpy commented 7 months ago

So, how would you like that to be handled?

That's the slide jump modifier, which I've not changed the factor of, just split it out into its own variable SLIDE_JUMP_MOD. If you change that to 1.0, you'll get normal jump height on doing this.

The reason it's higher than without this branch is I've made it so slide jumps put you into standing mode in terms of where the head camera gets placed. I can make it so you stay at crouched height instead visually, though ultimately you're still coming off the ground higher than a regular jump.

Phazorknight commented 7 months ago

Oh, apologies, I didn't realize this was an intended modifier. That's what I get for rushing. Changing the modifier did what you said and I was able to get the expected behaviour.

Will finish my review after lunch.