Closed Ferskken closed 2 years ago
todo:
[x] Fix player move speed when landing after jump. Currently the speed continues using the air movement modifier, until player releases movement key. This is caused by the input system callbacks being used to call action methods only triggering on a change to input. If the input is held after landing, movement speed continues to be affected by airMovement modifier. Possible solutions?
force a reset of move speed modifier when player object becomes grounded again (treats symptom, not cause)
Figure out how to make input system trigger a callback on player landing? (probably best option)
[x] Fix player movement stopping mid-air if input is released. Possibly caused by x-axis movement being stored in a variable set by Move(ctx) function, which is in turn used by Update() function to set movement speed. If there is no input, then moveInputX == 0, and movement speed == 0... Possible solutions?
Somehow retain x-axis speed if !isGrounded during Update?
Switch movement to use forces instead of setting velocity directly? (More realistic physics..)
Update:
These issue are fixed most of the way now. Still needs some tweaking to make it feel good. Solution was to change movement inputs to use addForce instead of setting rigid body velocity directly, along with some control logic.
We now apply a force in the input x-direction each update while velocity is below a specified max.
If input in x-direction is 0, then velocity is reduced geometrically each frame by a specified multiplier. This part still uses rb.velocity directly, and a better solution probably exists. The current implementation feels pretty good to play though.
A few changes still need to be implemented:
[ ] Fix jump. Current jump feels floaty, and is also completely binary. Jump height should correspond to length of time that jump button is held. Short jump for quick tap, tall jump for hold. Solutions:
Change jump to use addForce instead of velocity. This will probably get us most of the way there.
If jump uses addForce, tying jump height to input should be as simple as applying force while jump is held, up to a certain y-direction speed or a certain duration? Jump held == ctx.performed
? Or ctx.time <= jumpAirTime
?
Jump counter needs tweaking. It seems like it's not triggering on the first jump, or being reset immediately because of delayed update to isGrounded?
[ ] Fix wall jump. Current wall jump is simply using the double jump, i.e. it doesn't actually exist... This means that no wall jump can be performed if a double jump has been performed, and that repeated wall jumping isn't possible. Possible solution:
Implement colliders on both sides of player object that detect contact with wall layer objects. if onWall { Jump(diagonal away from wall)
Wall jump should work as long as any x-axis input is held, regardless of direction. This is how it seems to work in Celeste, and it makes chaining wall jumps feel really smooth.
No x-input while walljumping should add a weaker force to the RB.
[ ] Implement wall slide and/or grab
Grab: Freeze x & y position while holding a button and touching a wall?
Slide: Set a low-ish max negative y velocity while input is in same direction as wall?
Been playing Super Mario 3 and World for a bit today, trying to get a feel for how the movement is implemented.
To my surprise, the movement in SMB3 (considered by many, me included, to be one of the best platformers ever) actually feels really floaty... Floaty to the point where it took me some time to readjust my platforming instincts before I could play the game comfortably. The game actually felt sort of bad, until I got it dialled in... It almost had the same kind of floatiness that the prototype has. Some observations:
if running
, or do we use some fraction of x-velocity as scalar for y force on jumps? Probably additive, or at least a scalar like 1+x.velocity
to avoid multiplying jump by zero when standing still... Gonna have to do some more "research" here, before I can make any judgements... Initial thought are that it feels like SMB3 but with better tuning, which is no surprise.
Make a Basic Player with jump, walljump and double jump.