Struct PhysicsVelocity
The velocity of a rigid body. If absent, the rigid body is static.
Inherited Members
Namespace: Unity.Physics
Syntax
public struct PhysicsVelocity : IComponentData, IQueryTypeParameter
Fields
Angular
The body's angular velocity in radians per second about each principal axis specified by Transform . In order to get or set world-space values, use GetAngularVelocityWorldSpace(in PhysicsVelocity, in PhysicsMass, in quaternion) and SetAngularVelocityWorldSpace(ref PhysicsVelocity, in PhysicsMass, in quaternion, in float3), respectively.
Declaration
public float3 Angular
Field Value
Type | Description |
---|---|
float3 |
Linear
The body's world-space linear velocity in units per second.
Declaration
public float3 Linear
Field Value
Type | Description |
---|---|
float3 |
Zero
Zero Physics Velocity. All fields are initialized to zero.
Declaration
public static readonly PhysicsVelocity Zero
Field Value
Type | Description |
---|---|
PhysicsVelocity |
Methods
CalculateVelocityToTarget(in PhysicsMass, in float3, in quaternion, in RigidTransform, in Single)
Create a PhysicsVelocity required to move a body to a target position and orientation. Use this method to control kinematic bodies directly if they need to generate contact events when moving to their new positions. If you need to teleport kinematic bodies you can simply set their LocalTransform component values directly.
Declaration
public static PhysicsVelocity CalculateVelocityToTarget(in PhysicsMass bodyMass, in float3 bodyPosition, in quaternion bodyOrientation, in RigidTransform targetTransform, in float stepFrequency)
Parameters
Type | Name | Description |
---|---|---|
PhysicsMass | bodyMass | The body's PhysicsMass component. |
float3 | bodyPosition | The body's world-space position. |
quaternion | bodyOrientation | The body's world-space rotation. |
RigidTransform | targetTransform | The desired translation and rotation values the body should move to in world space. |
Single | stepFrequency | The step frequency in the simulation where the body's motion is solved (i.e., 1 / FixedDeltaTime). |
Returns
Type | Description |
---|---|
PhysicsVelocity | The calculated velocity to target. |