Skip to content
7 changes: 7 additions & 0 deletions include/config/config_movement.h
Original file line number Diff line number Diff line change
Expand Up @@ -142,3 +142,10 @@
*/
#define MARIO_INERTIA_UPWARD
// #define MARIO_INERTIA_LATERAL


/**
* Fixes Mario's walk speed on frame 1 being inconsistent due to controllers inputting low magnitude.
* This define makes accelerating from idle more consistent.
*/
#define FIX_WALK_SPEED_POLLING
13 changes: 13 additions & 0 deletions src/game/mario_actions_moving.c
Original file line number Diff line number Diff line change
Expand Up @@ -415,6 +415,11 @@ s32 update_decelerating_speed(struct MarioState *m) {
return stopped;
}

#ifdef FIX_WALK_SPEED_POLLING
// Velocity Mario gets when starting a walk frame 1.
#define START_WALK_VELOCITY 8.f
#endif

void update_walking_speed(struct MarioState *m) {
f32 maxTargetSpeed;
f32 targetSpeed;
Expand All @@ -435,6 +440,14 @@ void update_walking_speed(struct MarioState *m) {
// Slow down if moving backwards
m->forwardVel += 1.1f;
} else if (m->forwardVel <= targetSpeed) {
#ifdef FIX_WALK_SPEED_POLLING
// When starting a walk, make a few checks and set Mario's speed to 8 on the first frame.
// This ensures Mario's speed is set consistently.
if (m->forwardVel <= START_WALK_VELOCITY && m->prevAction == ACT_IDLE
&& !mario_floor_is_steep(m)) {
m->forwardVel = MIN(m->intendedMag, START_WALK_VELOCITY); // same fix as melee dashback
}
#endif
// If accelerating
m->forwardVel += 1.1f - m->forwardVel / 43.0f;
} else if (m->floor->normal.y >= 0.95f) {
Expand Down