Quick answer: Godot 4 RigidBody2D jittering when mass is changed during _physics_process? The solver is mid-step when the change applies - set mass via call_deferred or use PhysicsServer directly.
Pickup adds mass to the player. Player visibly stutters one frame on every pickup.
Defer the mass change
func on_pickup():
call_deferred("set", "mass", new_mass)Deferred sets apply between physics steps, not during them.
Use PhysicsServer2D
PhysicsServer2D.body_set_param(
body_rid, PhysicsServer2D.BODY_PARAM_MASS, new_mass)The server-level API doesn't have the same mid-step issue but skips Godot's normal change notifications.
Apply in physics_process, not signals
Signals fire mid-tick. Even setting mass directly inside one is mid-step. Queue the change and apply at the top of the next physics_process.
“Physics state changes mid-step are unsafe. Queue them.”
For variable-mass gameplay (cargo, snowball), pre-bake mass changes into discrete tiers. Three or four steps look the same to players and dodge the jitter.