Struct RigidBodyAspect
A rigid body aspect. Contatins transform data, mass, mass overide, velocity, damping and gravity factor information.
Inherited Members
Namespace: Unity.Physics.Aspects
Assembly: Unity.Physics.dll
Syntax
public readonly struct RigidBodyAspect : IAspect, IAspectCreate<RigidBodyAspect>, IQueryTypeParameter
Constructors
RigidBodyAspect(Entity, RefRW<PhysicsCollider>, RefRW<PhysicsDamping>, RefRW<PhysicsGravityFactor>, RefRW<PhysicsMass>, RefRW<PhysicsMassOverride>, RefRW<PhysicsVelocity>, RefRW<LocalTransform>)
Construct an instance of the enclosing aspect from all required data references.
Declaration
public RigidBodyAspect(Entity rigidbodyaspect_entityE, RefRW<PhysicsCollider> rigidbodyaspect_m_colliderRef, RefRW<PhysicsDamping> rigidbodyaspect_m_dampingRef, RefRW<PhysicsGravityFactor> rigidbodyaspect_m_gravityfactorRef, RefRW<PhysicsMass> rigidbodyaspect_m_massRef, RefRW<PhysicsMassOverride> rigidbodyaspect_m_massoverideRef, RefRW<PhysicsVelocity> rigidbodyaspect_m_velocityRef, RefRW<LocalTransform> rigidbodyaspect_m_transformRef)
Parameters
Type | Name | Description |
---|---|---|
Entity | rigidbodyaspect_entityE | |
RefRW<PhysicsCollider> | rigidbodyaspect_m_colliderRef | |
RefRW<PhysicsDamping> | rigidbodyaspect_m_dampingRef | |
RefRW<PhysicsGravityFactor> | rigidbodyaspect_m_gravityfactorRef | |
RefRW<PhysicsMass> | rigidbodyaspect_m_massRef | |
RefRW<PhysicsMassOverride> | rigidbodyaspect_m_massoverideRef | |
RefRW<PhysicsVelocity> | rigidbodyaspect_m_velocityRef | |
RefRW<LocalTransform> | rigidbodyaspect_m_transformRef |
Fields
Entity
The entity of this aspect.
Declaration
public readonly Entity Entity
Field Value
Type | Description |
---|---|
Entity |
Properties
AngularDamping
Gets or sets the angular damping.
Declaration
public float AngularDamping { get; set; }
Property Value
Type | Description |
---|---|
float | The angular damping. |
AngularVelocityLocalSpace
Gets or sets the angular velocity in local space.
Declaration
public float3 AngularVelocityLocalSpace { get; set; }
Property Value
Type | Description |
---|---|
float3 | The angular velocity in local space. |
AngularVelocityWorldSpace
Gets or sets the angular velocity in world space.
Declaration
public float3 AngularVelocityWorldSpace { get; set; }
Property Value
Type | Description |
---|---|
float3 | The angular velocity in world space. |
CenterOfMassLocalSpace
Gets or sets the center of mass in local space.
Declaration
public float3 CenterOfMassLocalSpace { get; set; }
Property Value
Type | Description |
---|---|
float3 | The center of mass in local space. |
CenterOfMassWorldSpace
Gets or sets the center of mass in world space.
Declaration
public float3 CenterOfMassWorldSpace { get; set; }
Property Value
Type | Description |
---|---|
float3 | The center of mass in world space. |
GravityFactor
Gets or sets the gravity factor.
Declaration
public float GravityFactor { get; set; }
Property Value
Type | Description |
---|---|
float | The gravity factor. |
Inertia
Gets or sets the inertia.
Declaration
public float3 Inertia { get; set; }
Property Value
Type | Description |
---|---|
float3 | The inertia. |
IsKinematic
Gets or sets a value indicating whether this object is kinematic.
Declaration
public bool IsKinematic { get; set; }
Property Value
Type | Description |
---|---|
bool | True if this object is kinematic, false if not. |
LinearDamping
Gets or sets the linear damping.
Declaration
public float LinearDamping { get; set; }
Property Value
Type | Description |
---|---|
float | The linear damping. |
LinearVelocity
Gets or sets the linear velocity.
Declaration
public float3 LinearVelocity { get; set; }
Property Value
Type | Description |
---|---|
float3 | The linear velocity. |
Mass
Gets or sets the mass.
Declaration
public float Mass { get; set; }
Property Value
Type | Description |
---|---|
float | The mass. |
Position
Gets or sets the world space position.
Declaration
public float3 Position { get; set; }
Property Value
Type | Description |
---|---|
float3 | The world space position. |
Rotation
Gets or sets the world space rotation.
Declaration
public quaternion Rotation { get; set; }
Property Value
Type | Description |
---|---|
quaternion | The world space rotation. |
Scale
Gets or sets the uniform scale.
Declaration
public float Scale { get; set; }
Property Value
Type | Description |
---|---|
float | The scale. |
WorldFromBody
Gets or sets the world transform of this aspect.
Declaration
public LocalTransform WorldFromBody { get; set; }
Property Value
Type | Description |
---|---|
LocalTransform | The world space transform. |
Methods
AddComponentRequirementsTo(ref UnsafeList<ComponentType>)
Add component requirements from this aspect into all archetype lists.
Declaration
public void AddComponentRequirementsTo(ref UnsafeList<ComponentType> all)
Parameters
Type | Name | Description |
---|---|---|
UnsafeList<ComponentType> | all | Archetype "all" component requirements. |
AddRequiredComponentTypes(ref Span<ComponentType>)
Add component requirements from this aspect into the provided span.
Declaration
public static void AddRequiredComponentTypes(ref Span<ComponentType> componentTypes)
Parameters
Type | Name | Description |
---|---|---|
Span<ComponentType> | componentTypes | The span to which all required components in this aspect are added. |
ApplyAngularImpulseLocalSpace(float3)
Applies the angular impulse in local space.
Declaration
public void ApplyAngularImpulseLocalSpace(float3 impulse)
Parameters
Type | Name | Description |
---|---|---|
float3 | impulse | The impulse to apply. |
ApplyAngularImpulseWorldSpace(float3)
Applies the angular impulse in world space.
Declaration
public void ApplyAngularImpulseWorldSpace(float3 impulse)
Parameters
Type | Name | Description |
---|---|---|
float3 | impulse | The impulse to apply. |
ApplyExplosiveImpulse(float, float3, float, float3, float)
Applies the explosive impulse.
Declaration
public void ApplyExplosiveImpulse(float impulse, float3 explosionPositionWorldSpace, float explosionRadius, float3 up, float upwardsModifier = 0)
Parameters
Type | Name | Description |
---|---|---|
float | impulse | The impulse. |
float3 | explosionPositionWorldSpace | The explosion position world space. |
float | explosionRadius | The explosion radius. |
float3 | up | The up vector. |
float | upwardsModifier | (Optional) The upwards modifier. |
ApplyExplosiveImpulse(float, float3, float, float3, CollisionFilter, float)
Applies the explosive impulse.
Declaration
public void ApplyExplosiveImpulse(float impulse, float3 explosionPositionWorldSpace, float explosionRadius, float3 up, CollisionFilter filter, float upwardsModifier = 0)
Parameters
Type | Name | Description |
---|---|---|
float | impulse | The impulse. |
float3 | explosionPositionWorldSpace | The explosion position world space. |
float | explosionRadius | The explosion radius. |
float3 | up | The up vector. |
CollisionFilter | filter |
applied to the impulse. |
float | upwardsModifier | (Optional) The upwards modifier. |
ApplyImpulseAtPointLocalSpace(float3, float3)
Applies the impulse at point in local space.
Declaration
public void ApplyImpulseAtPointLocalSpace(float3 impulse, float3 pointLocalSpace)
Parameters
Type | Name | Description |
---|---|---|
float3 | impulse | The impulse. |
float3 | pointLocalSpace | The point in local space. |
ApplyImpulseAtPointWorldSpace(float3, float3)
Applies the impulse at point in world space.
Declaration
public void ApplyImpulseAtPointWorldSpace(float3 impulse, float3 pointWorldSpace)
Parameters
Type | Name | Description |
---|---|---|
float3 | impulse | The impulse. |
float3 | pointWorldSpace | The point in world space. |
ApplyLinearImpulseLocalSpace(float3)
Applies the linear impulse in local space.
Declaration
public void ApplyLinearImpulseLocalSpace(float3 impulse)
Parameters
Type | Name | Description |
---|---|---|
float3 | impulse | The impulse to apply. |
ApplyLinearImpulseWorldSpace(float3)
Applies the linear impulse in world space.
Declaration
public void ApplyLinearImpulseWorldSpace(float3 impulse)
Parameters
Type | Name | Description |
---|---|---|
float3 | impulse | The impulse to apply. |
CompleteDependencyBeforeRO(ref SystemState)
Completes the dependency chain required for this aspect to have read access. So it completes all write dependencies of the components, buffers, etc. to allow for reading.
Declaration
public void CompleteDependencyBeforeRO(ref SystemState state)
Parameters
Type | Name | Description |
---|---|---|
SystemState | state | The Unity.Entities.SystemState containing an Unity.Entities.EntityManager storing all dependencies. |
CompleteDependencyBeforeRW(ref SystemState)
Completes the dependency chain required for this component to have read and write access. So it completes all write dependencies of the components, buffers, etc. to allow for reading, and it completes all read dependencies, so we can write to it.
Declaration
public void CompleteDependencyBeforeRW(ref SystemState state)
Parameters
Type | Name | Description |
---|---|---|
SystemState | state | The Unity.Entities.SystemState containing an Unity.Entities.EntityManager storing all dependencies. |
CreateAspect(Entity, ref SystemState)
Create an instance of the enclosing aspect struct pointing at a specific entity's components data.
Declaration
public RigidBodyAspect CreateAspect(Entity entity, ref SystemState systemState)
Parameters
Type | Name | Description |
---|---|---|
Entity | entity | The entity to create the aspect struct from. |
SystemState | systemState | The system state from which data is extracted. |
Returns
Type | Description |
---|---|
RigidBodyAspect | Instance of the aspect struct pointing at a specific entity's components data. |
GetEffectiveMassLocalSpace(float3, float3)
Gets effective mass in local space.
Declaration
public float GetEffectiveMassLocalSpace(float3 impulse, float3 pointLocalSpace)
Parameters
Type | Name | Description |
---|---|---|
float3 | impulse | The impulse. |
float3 | pointLocalSpace | The point in local space. |
Returns
Type | Description |
---|---|
float | The effective mass local space. |
GetEffectiveMassWorldSpace(float3, float3)
Gets effective mass in world space.
Declaration
public float GetEffectiveMassWorldSpace(float3 impulse, float3 pointWorldSpace)
Parameters
Type | Name | Description |
---|---|---|
float3 | impulse | The impulse. |
float3 | pointWorldSpace | The point in world space. |
Returns
Type | Description |
---|---|
float | The effective mass in world space. |
GetLinearVelocityAtPointLocalSpace(float3)
Gets linear velocity at point in local space.
Declaration
public float3 GetLinearVelocityAtPointLocalSpace(float3 pointLocalSpace)
Parameters
Type | Name | Description |
---|---|---|
float3 | pointLocalSpace | The point in local space. |
Returns
Type | Description |
---|---|
float3 | The linear velocity at point in local space. |
GetLinearVelocityAtPointWorldSpace(float3)
Gets linear velocity at point in world space.
Declaration
public float3 GetLinearVelocityAtPointWorldSpace(float3 pointWorldSpace)
Parameters
Type | Name | Description |
---|---|---|
float3 | pointWorldSpace | The point in world space. |
Returns
Type | Description |
---|---|
float3 | The linear velocity at point in world space. |
GetRequiredComponentTypeCount()
Get the number of required (i.e. non-optional) components contained in this aspect.
Declaration
public static int GetRequiredComponentTypeCount()
Returns
Type | Description |
---|---|
int | The number of required (i.e. non-optional) components contained in this aspect. |
Query(EntityQuery, TypeHandle)
Enumerate the enclosing aspect from all entities in a query.
Declaration
public static RigidBodyAspect.Enumerator Query(EntityQuery query, RigidBodyAspect.TypeHandle typeHandle)
Parameters
Type | Name | Description |
---|---|---|
EntityQuery | query | The entity query to enumerate. |
RigidBodyAspect.TypeHandle | typeHandle | The aspect's enclosing type handle. |
Returns
Type | Description |
---|---|
RigidBodyAspect.Enumerator | An enumerator of all the entities instance of the enclosing aspect. |