Skip to content

Animator Sync To Rigidbody2D

Sets float parameters on the Animator based on the velocity state of a Rigidbody2D.

Parameters

Parameter Description
Animator The Animator component to sync parameters on.
Rigidbody The Rigidbody2D to read velocity from.
Sync Speed A float parameter to set to the total speed magnitude.
Sync Speed X A float parameter to set to the horizontal velocity.
Sync Absolute Speed X A float parameter to set to the absolute horizontal speed (negative values become positive).
Sync Speed Y A float parameter to set to the vertical velocity.
Sync Absolute Speed Y A float parameter to set to the absolute vertical speed (negative values become positive).
Maximum Speed Used to normalize speeds. If your blend tree uses 0-1 range and your character's max speed is 10, set this to 10. Not used if set to zero.

⚙ Details

This action runs every frame by default to continuously sync Rigidbody2D velocity data to Animator parameters.

Speed Calculations:

  • Speed: velocity.magnitude - total movement speed
  • Speed X/Y: Direct velocity components (can be negative)
  • Absolute Speed X/Y: Mathf.Abs() of velocity components (always positive)

Debugging

You can monitor the Animator window to see parameter values updating in real-time, or use the Animator's debug mode to visualize blend tree states.

Examples

This action is essential for 2D character animation systems that need to respond to movement:

2D Platformer Character:

  • Set Sync Speed to "MovementSpeed" for walk/run blend trees
  • Set Sync Speed Y to "VerticalSpeed" to trigger jump/fall animations
  • Set Maximum Speed to the character's move speed to normalize a 0-1 blend tree range

2D Side-Scroller:

  • Set Sync Absolute Speed X to "Speed" for movement animations regardless of direction
  • Set Sync Speed Y to "YVelocity" for jump state detection
  • Normalize with character's actual maximum movement speed

Top-Down 2D Movement:

  • Set Sync Speed to "MoveSpeed" for idle/walk/run transitions
  • Set Sync Speed X and Sync Speed Y for directional animations
  • Use 8-directional blend trees with normalized X/Y inputs

This approach automatically keeps your 2D animations synchronized with physics movement without manual scripting.

Performance

The action converts parameter names to hash IDs during OnStart() for better performance during execution. Only parameters with assigned names are updated each frame, using the efficient Animator.SetFloat(int, float) overload with pre-computed hash IDs.