Rigidbody.velocity is obsolete in Unity 6: use linearVelocity

Unity 6 renamed Rigidbody.velocity and Rigidbody2D.velocity to linearVelocity. What changed, the one-line fix, and how to keep code compiling on 2022.3 too.

Status
Obsolete since Unity 6.0 · Physics
Old
Rigidbody.velocity, Rigidbody2D.velocity
New
Rigidbody.linearVelocity, Rigidbody2D.linearVelocity
Checked
2026-10-05, against the sources below

What changed

In Unity 6.0, the velocity property on both Rigidbody and Rigidbody2D was renamed to linearVelocity, to sit alongside angularVelocity and the new linearDamping. The value and units are unchanged: it is still the body's velocity in world units per second, so the fix is a rename.

Rigidbody2D also gained linearVelocityX and linearVelocityY, which let you set one axis without building a new Vector2. Other components that have a velocity, such as CharacterController and NavMeshAgent, did not change; only rigidbodies did.

If the same code must compile on Unity 2022.3 as well, wrap the property in a version check, as in the last example below.

Before and after

Before
C#
Rigidbody2D rb;

void Jump()
{
    rb.velocity = new Vector2(rb.velocity.x, jumpForce);
}
After
C#
Rigidbody2D rb;

void Jump()
{
    rb.linearVelocity = new Vector2(rb.linearVelocity.x, jumpForce);
    // Unity 6 also lets you set one axis directly:
    // rb.linearVelocityY = jumpForce;
}

Compile on Unity 2022.3 and Unity 6

For a package or asset that still supports 2022.3, branch on Unity's version define:

Both versions
C#
#if UNITY_6000_0_OR_NEWER
    rb.linearVelocity = new Vector2(rb.linearVelocity.x, jumpForce);
#else
    rb.velocity = new Vector2(rb.velocity.x, jumpForce);
#endif

Fix it automatically

Paste a script into the Unity 6 Script Upgrade Checker and it applies this rename for you, along with the other safe fixes for your target version.

Open this example in the checker

Questions

Will code that uses velocity still compile in Unity 6?
Yes, for now. velocity is marked obsolete, so it compiles with a CS0618 warning and still works. Obsolete APIs are removed in later versions, as the ModelImporter APIs were in 6.5, so rename it while the change is one word.
Do CharacterController and NavMeshAgent use linearVelocity too?
No. Only Rigidbody and Rigidbody2D changed. CharacterController.velocity and NavMeshAgent.velocity keep their names, so a find-and-replace across the whole project would break them; rename only the rigidbody calls.

Sources

Related Unity 6 changes

Every Unity 6.x change, by version