Component · physics2d
Velocity2d
Authoritative velocity, synchronized at tick boundaries.
Fields
linear
vec2World-space linear velocity.
default [0,0]m/sreplicated · relevant, rollback
angular
f32Counter-clockwise angular velocity.
default 0rad/sreplicated · relevant, rollback
Usage
Every edit is an undoable command: from the CLI as below, or the same JSON from an agent over MCP. See component.add and property.set.
Add it
ara do component.add -p entity=name:Crate -p component=Velocity2d --why "Add Velocity2d"Set a field
ara do property.set -p entity=name:Crate -p path=Velocity2d.linear -p value=[0,0] --why "Tune Velocity2d"In a scene document
{
"Velocity2d": {
"linear": [
0,
0
]
}
}From C#
/// <summary>Apply a horizontal 2D velocity impulse.</summary>
public static void UseVelocity2d(Entity entity, in Tick tick)
{
ref var component = ref World.Get<Velocity2d>(entity);
component.Linear += new Vector2(2, 0);
}From C#
Scripts read and write it with Get<Velocity2d>(); see the Velocity2d struct.