Skip to content

Rigidbody2D Set Velocity If Input Axis Not Zero

Sets Rigidbody2D velocity only on axes where the input exceeds a threshold.

Parameters

Parameter Description
Rigidbody2D The Rigidbody2D to modify.
Input Velocity input to apply per axis.
Threshold Axis magnitudes below this are treated as zero.
Relative To Space used when applying the velocity.

Notes

  • This is useful when horizontal and vertical control should update independently.