Class PhysicsComponentExtensions | Unity Physics | 0.5.1-preview.2
docs.unity3d.com
    Show / Hide Table of Contents

    Class PhysicsComponentExtensions

    Utility functions acting on physics components.

    Inheritance
    Object
    PhysicsComponentExtensions
    Namespace: Unity.Physics.Extensions
    Syntax
    public static class PhysicsComponentExtensions

    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. ExplosionFilter is set to CollisionFIlter.Default ApplyExplosionForce(ref PhysicsVelocity, PhysicsMass, PhysicsCollider, Translation, Rotation, Single, float3, Single, Single, float3, CollisionFilter, Single, ForceMode)

    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
    PhysicsMass bodyMass
    PhysicsCollider bodyCollider
    Translation bodyPosition
    Rotation bodyOrientation
    Single explosionForce
    Unity.Mathematics.float3 explosionPosition
    Single explosionRadius
    Single timestep
    Unity.Mathematics.float3 up
    Single upwardsModifier
    ForceMode mode

    ApplyExplosionForce(ref PhysicsVelocity, PhysicsMass, PhysicsCollider, Translation, Rotation, Single, float3, Single, Single, float3, CollisionFilter, 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 CollisionFilter explosionFilter, 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.

    CollisionFilter explosionFilter

    Filter determining whether an explosion should be applied to the body.

    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

    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

    GetCenterOfMassWorldSpace(PhysicsMass, Translation, Rotation)

    Get the center of mass in world space

    Declaration
    public static float3 GetCenterOfMassWorldSpace(this in 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

    GetEffectiveMass(PhysicsMass, Translation, Rotation, float3, float3)

    Get a body's effective mass in a given direction and from a particular point in world space.

    Declaration
    public static float GetEffectiveMass(this in PhysicsMass bodyMass, in Translation bodyPosition, in Rotation bodyOrientation, float3 impulse, float3 point)
    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 impulse

    An impulse in world space.

    Unity.Mathematics.float3 point

    A point in world space.

    Returns
    Type Description
    Single

    A body's effective mass with respect to the specified point and impulse.

    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 in 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)

    Integrate(PhysicsVelocity, PhysicsMass, Single, ref float3, ref quaternion)

    Compute a future position and orientation for a dynamic rigid body based on its current trajectory, after a specified amount of time.

    Declaration
    public static void Integrate(this in PhysicsVelocity physicsVelocity, in PhysicsMass physicsMass, float timestep, ref float3 position, ref quaternion orientation)
    Parameters
    Type Name Description
    PhysicsVelocity physicsVelocity

    The body's PhysicsVelocity component.

    PhysicsMass physicsMass

    The body's PhysicsMass component.

    Single timestep

    The change in time from the current to the next frame.

    Unity.Mathematics.float3 position

    The future position of the body.

    Unity.Mathematics.quaternion orientation

    The future orientation of the body.

    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.

    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

    Back to top
    Copyright © 2023 Unity Technologies — Terms of use
    • Legal
    • Privacy Policy
    • Cookies
    • Do Not Sell or Share My Personal Information
    • Your Privacy Choices (Cookie Settings)
    "Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
    Generated by DocFX on 18 October 2023