Class ComponentExtensions
Namespace: Unity.Physics.Extensions
Syntax
public static class ComponentExtensions
Methods
ApplyAngularImpulse(ref PhysicsVelocity, PhysicsMass, float3)
Declaration
public static void ApplyAngularImpulse(this ref PhysicsVelocity velocityData, in PhysicsMass massData, in float3 impulse)
Parameters
Type | Name | Description |
---|---|---|
PhysicsVelocity | velocityData | |
PhysicsMass | massData | |
Unity.Mathematics.float3 | impulse |
ApplyExplosionForce(ref PhysicsVelocity, PhysicsMass, PhysicsCollider, Translation, Rotation, Single, float3, Single, Single, float3, Single, ForceMode)
Converts a force into an impulse based on the force mode and the bodies mass and inertia properties. Equivalent to UnityEngine.Rigidbody.AddExplosionForce
Declaration
public static void ApplyExplosionForce(this ref PhysicsVelocity bodyVelocity, in PhysicsMass bodyMass, in PhysicsCollider bodyCollider, in Translation bodyPosition, in Rotation bodyOrientation, float explosionForce, in float3 explosionPosition, in float explosionRadius, in float timeStep, in float3 up, in float upwardsModifier = 0F, ForceMode mode = ForceMode.Force)
Parameters
Type | Name | Description |
---|---|---|
PhysicsVelocity | bodyVelocity | The body's PhysicsVelocity component. |
PhysicsMass | bodyMass | The body's PhysicsMass component. |
PhysicsCollider | bodyCollider | The body's PhysicsCollider component. |
Translation | bodyPosition | The body's Translation component. |
Rotation | bodyOrientation | The body's Rotation component. |
Single | explosionForce | The force of the explosion (which may be modified by distance). |
Unity.Mathematics.float3 | explosionPosition | The centre of the sphere within which the explosion has its effect. |
Single | explosionRadius | The radius of the sphere within which the explosion has its effect. |
Single | timeStep | The change in time from the current to the next frame. |
Unity.Mathematics.float3 | up | A vector defining the up direction, generally a unit vector in the opposite direction to PhysicsStep.Gravity. |
Single | upwardsModifier | Adjustment to the apparent position of the explosion to make it seem to lift objects. |
ForceMode | mode | The method used to apply the force to its targets. |
ApplyImpulse(ref PhysicsVelocity, PhysicsMass, Translation, Rotation, float3, float3)
Declaration
public static void ApplyImpulse(this ref PhysicsVelocity pv, in PhysicsMass pm, in Translation t, in Rotation r, in float3 impulse, in float3 point)
Parameters
Type | Name | Description |
---|---|---|
PhysicsVelocity | pv | |
PhysicsMass | pm | |
Translation | t | |
Rotation | r | |
Unity.Mathematics.float3 | impulse | |
Unity.Mathematics.float3 | point |
ApplyLinearImpulse(ref PhysicsVelocity, PhysicsMass, float3)
Declaration
public static void ApplyLinearImpulse(this ref PhysicsVelocity velocityData, in PhysicsMass massData, in float3 impulse)
Parameters
Type | Name | Description |
---|---|---|
PhysicsVelocity | velocityData | |
PhysicsMass | massData | |
Unity.Mathematics.float3 | impulse |
GetAngularVelocity(PhysicsVelocity, PhysicsMass, Rotation)
Declaration
[Obsolete("Renamed to GetAngularVelocityWorldSpace() (RemovedAfter 2020-08-11) (UnityUpgradable) -> ComponentExtensions.GetAngularVelocityWorldSpace(*)")]
public static float3 GetAngularVelocity(this PhysicsVelocity velocityData, PhysicsMass massData, Rotation rotData)
Parameters
Type | Name | Description |
---|---|---|
PhysicsVelocity | velocityData | |
PhysicsMass | massData | |
Rotation | rotData |
Returns
Type | Description |
---|---|
Unity.Mathematics.float3 |
GetAngularVelocityWorldSpace(PhysicsVelocity, PhysicsMass, Rotation)
Get the world-space angular velocity of a rigid body.
Declaration
public static float3 GetAngularVelocityWorldSpace(this in PhysicsVelocity bodyVelocity, in PhysicsMass bodyMass, in Rotation bodyOrientation)
Parameters
Type | Name | Description |
---|---|---|
PhysicsVelocity | bodyVelocity | The body's PhysicsVelocity component. |
PhysicsMass | bodyMass | The body's PhysicsMass component |
Rotation | bodyOrientation | The body's Rotation component |
Returns
Type | Description |
---|---|
Unity.Mathematics.float3 | The angular velocity of a rigid body in world space |
GetCenterOfMass(PhysicsMass, Translation, Rotation)
Declaration
[Obsolete("Renamed to GetCenterOfMassWorldSpace() (RemovedAfter 2020-08-11) (UnityUpgradable) -> ComponentExtensions.GetCenterOfMassWorldSpace(*)")]
public static float3 GetCenterOfMass(this PhysicsMass massData, Translation posData, Rotation rotData)
Parameters
Type | Name | Description |
---|---|---|
PhysicsMass | massData | |
Translation | posData | |
Rotation | rotData |
Returns
Type | Description |
---|---|
Unity.Mathematics.float3 |
GetCenterOfMassWorldSpace(ref PhysicsMass, Translation, Rotation)
Get the center of mass in world space
Declaration
public static float3 GetCenterOfMassWorldSpace(this ref PhysicsMass bodyMass, in Translation bodyPosition, in Rotation bodyOrientation)
Parameters
Type | Name | Description |
---|---|---|
PhysicsMass | bodyMass | The body's PhysicsMass component |
Translation | bodyPosition | The body's Translation component |
Rotation | bodyOrientation | The body's Rotation component |
Returns
Type | Description |
---|---|
Unity.Mathematics.float3 | The center of mass in world space |
GetImpulseFromForce(PhysicsMass, float3, ForceMode, Single, out float3, out PhysicsMass)
Converts a force into an impulse based on the force mode and the bodies mass and inertia properties.
Declaration
public static void GetImpulseFromForce(this in PhysicsMass bodyMass, in float3 force, in ForceMode mode, in float timeStep, out float3 impulse, out PhysicsMass impulseMass)
Parameters
Type | Name | Description |
---|---|---|
PhysicsMass | bodyMass | The body's PhysicsMass component. |
Unity.Mathematics.float3 | force | The force to be applied to a body. |
ForceMode | mode | The method used to apply the force to its targets. |
Single | timeStep | The change in time from the current to the next frame. |
Unity.Mathematics.float3 | impulse | A returned impulse proportional to the provided 'force' and based on the supplied 'mode'. |
PhysicsMass | impulseMass | A returned PhysicsMass component to be passed to an Apply function. |
GetLinearVelocity(PhysicsVelocity, PhysicsMass, Translation, Rotation, float3)
Get the linear velocity of a rigid body at a given point (in world space)
Declaration
public static float3 GetLinearVelocity(this PhysicsVelocity bodyVelocity, PhysicsMass bodyMass, Translation bodyPosition, Rotation bodyOrientation, float3 point)
Parameters
Type | Name | Description |
---|---|---|
PhysicsVelocity | bodyVelocity | The body's PhysicsVelocity component. |
PhysicsMass | bodyMass | The body's PhysicsMass component |
Translation | bodyPosition | The body's Translation component |
Rotation | bodyOrientation | The body's Rotation component |
Unity.Mathematics.float3 | point | A reference position in world space |
Returns
Type | Description |
---|---|
Unity.Mathematics.float3 | The linear velocity of a rigid body at a given point (in world space) |
SetAngularVelocity(PhysicsVelocity, PhysicsMass, Rotation, float3)
Declaration
[Obsolete("Renamed to SetAngularVelocityWorldSpace() (RemovedAfter 2020-08-11) (UnityUpgradable) -> ComponentExtensions.SetAngularVelocityWorldSpace(*)")]
public static void SetAngularVelocity(this PhysicsVelocity velocityData, PhysicsMass massData, Rotation rotData, float3 angularVelocity)
Parameters
Type | Name | Description |
---|---|---|
PhysicsVelocity | velocityData | |
PhysicsMass | massData | |
Rotation | rotData | |
Unity.Mathematics.float3 | angularVelocity |
SetAngularVelocityWorldSpace(ref PhysicsVelocity, PhysicsMass, Rotation, float3)
Set the world-space angular velocity of a rigid body.
Declaration
public static void SetAngularVelocityWorldSpace(this ref PhysicsVelocity bodyVelocity, in PhysicsMass bodyMass, in Rotation bodyOrientation, in float3 angularVelocity)
Parameters
Type | Name | Description |
---|---|---|
PhysicsVelocity | bodyVelocity | The body's PhysicsVelocity component. |
PhysicsMass | bodyMass | The body's PhysicsMass component |
Rotation | bodyOrientation | The body's Rotation component |
Unity.Mathematics.float3 | angularVelocity | An angular velocity in world space specifying radians per second about each axis. |
SetCenterOfMass(ref PhysicsMass, Translation, Rotation, float3)
Declaration
[Obsolete("Renamed to SetCenterOfMassWorldSpace() (RemovedAfter 2020-08-11) (UnityUpgradable) -> ComponentExtensions.SetCenterOfMassWorldSpace(*)")]
public static void SetCenterOfMass(this ref PhysicsMass massData, Translation posData, Rotation rotData, float3 com)
Parameters
Type | Name | Description |
---|---|---|
PhysicsMass | massData | |
Translation | posData | |
Rotation | rotData | |
Unity.Mathematics.float3 | com |
SetCenterOfMassWorldSpace(ref PhysicsMass, Translation, Rotation, float3)
Set the center of mass in world space
Declaration
public static void SetCenterOfMassWorldSpace(this ref PhysicsMass bodyMass, in Translation bodyPosition, in Rotation bodyOrientation, float3 com)
Parameters
Type | Name | Description |
---|---|---|
PhysicsMass | bodyMass | The body's PhysicsMass component |
Translation | bodyPosition | The body's Translation component |
Rotation | bodyOrientation | The body's Rotation component |
Unity.Mathematics.float3 | com | A position in world space for the new Center Of Mass |