Search Results for

    Show / Hide Table of Contents

    Class RigidBody

    Physics simulation driven object.

    Inheritance
    System.Object
    Object
    SceneObject
    Actor
    RigidBody
    WheeledVehicle
    Implements
    ISerializable
    Inherited Members
    Actor.SetLayerRecursive(Int32)
    Actor.SetLayerNameRecursive(String)
    Actor.HasTag()
    Actor.HasTag(Tag)
    Actor.HasTag(String)
    Actor.AddTag(Tag)
    Actor.AddTagRecursive(Tag)
    Actor.RemoveTag(Tag)
    Actor.SetParent(Actor, Boolean, Boolean)
    Actor.GetChild(Int32)
    Actor.GetChild(String)
    Actor.GetChild(Type)
    Actor.GetChildren(Type)
    Actor.DestroyChildren(Single)
    Actor.GetScript(Int32)
    Actor.GetScript(Type)
    Actor.GetScripts(Type)
    Actor.AddMovement(Vector3)
    Actor.AddMovement(Vector3, Quaternion)
    Actor.GetWorldToLocalMatrix(Matrix)
    Actor.GetLocalToWorldMatrix(Matrix)
    Actor.OnDebugDraw()
    Actor.OnDebugDrawSelected()
    Actor.GetPrefabRoot()
    Actor.FindActor(String)
    Actor.FindActor(Type, Boolean)
    Actor.FindActor(Type, String)
    Actor.FindActor(Type, Tag, Boolean)
    Actor.FindScript(Type)
    Actor.HasActorInHierarchy(Actor)
    Actor.HasActorInChildren(Actor)
    Actor.IntersectsItself(Ray, Single, Vector3)
    Actor.Intersects(Ray, Single, Vector3)
    Actor.LookAt(Vector3)
    Actor.LookAt(Vector3, Vector3)
    Actor.LookingAt(Vector3)
    Actor.LookingAt(Vector3, Vector3)
    Actor.ToBytes(Actor[])
    Actor.FromBytes(Byte[])
    Actor.FromBytes(Byte[], Dictionary<Guid, Guid>)
    Actor.TryGetSerializedObjectsIds(Byte[])
    Actor.ToJson()
    Actor.FromJson(String)
    Actor.Clone()
    Actor.OnEnable()
    Actor.OnDisable()
    Actor.OnParentChanged()
    Actor.OnTransformChanged()
    Actor.OnActiveChanged()
    Actor.OnActiveInTreeChanged()
    Actor.OnOrderInParentChanged()
    Actor.OnStaticFlagsChanged()
    Actor.OnLayerChanged()
    Actor.OnBeginPlay()
    Actor.OnEndPlay()
    Actor.AddStaticFlags(StaticFlags)
    Actor.RemoveStaticFlags(StaticFlags)
    Actor.SetStaticFlag(StaticFlags, Boolean)
    Actor.HasStaticFlag(StaticFlags)
    Actor.ResetLocalTransform()
    Actor.AddChild(Type)
    Actor.AddChild<T>()
    Actor.GetChild<T>()
    Actor.TryGetChild<T>(T)
    Actor.GetOrAddChild<T>()
    Actor.AddScript(Type)
    Actor.AddScript<T>()
    Actor.GetScript<T>()
    Actor.TryGetScript<T>(T)
    Actor.FindScript<T>()
    Actor.FindActor<T>(Boolean)
    Actor.FindActor<T>(String)
    Actor.FindActor<T>(Tag, Boolean)
    Actor.GetChildren<T>()
    Actor.GetScripts<T>()
    Actor.RotateAround(Vector3, Vector3, Single, Boolean)
    Actor.ToString()
    Actor.Children
    Actor.Tags
    Actor.Layer
    Actor.Name
    Actor.IsActive
    Actor.StaticFlags
    Actor.PerInstanceRandom
    Actor.LocalPosition
    Actor.LocalOrientation
    Actor.LocalScale
    Actor.Sphere
    Actor.Box
    Actor.BoxWithChildren
    Actor.EditorBox
    Actor.EditorBoxChildren
    Actor.HasContentLoaded
    Actor.IsPrefabRoot
    Actor.IsStatic
    Actor.IsTransformStatic
    Actor.WorldToLocalMatrix
    Actor.LocalToWorldMatrix
    SceneObject.SetParent(Actor, Boolean)
    SceneObject.LinkPrefab(Guid, Guid)
    SceneObject.BreakPrefabLink()
    SceneObject.GetNamePath(Char)
    SceneObject.IsDuringPlay
    SceneObject.HasParent
    SceneObject.HasPrefabLink
    SceneObject.PrefabID
    SceneObject.PrefabObjectID
    Object.__unmanagedPtr
    Object.__internalId
    Object.Finalize()
    Object.As<T>()
    Object.NewValue(Type)
    Object.New(String)
    Object.Find<T>(Guid, Boolean)
    Object.Find(Guid, Type, Boolean)
    Object.TryFind<T>(Guid)
    Object.TryFind(Guid, Type)
    Object.Destroy(Object, Single)
    Object.DestroyNow(Object)
    Object.Destroy<T>(T, Single)
    Object.Equals(Object)
    Object.GetUnmanagedPtr(Object)
    Object.GetUnmanagedInterface(Object, Type)
    Object.FromUnmanagedPtr(IntPtr)
    Object.MapObjectID(Guid)
    Object.RemapObjectID(Guid)
    Object.GetHashCode()
    Object.ID
    Object.TypeName
    Namespace: FlaxEngine
    Assembly: FlaxEngine.CSharp.dll
    Syntax
    [ActorContextMenu("New/Physics/Rigid Body")]
    [ActorToolbox("Physics")]
    [Unmanaged]
    public class RigidBody : Actor, ISerializable

    Constructors

    RigidBody()

    Initializes a new instance of the RigidBody.

    Declaration
    public RigidBody()

    Properties

    AngularDamping

    Gets or sets the 'drag' force added to reduce angular movement. Angular damping can be used to slow down the rotation of an object. The higher the drag the more the rotation slows down.

    Declaration
    [EditorOrder(70)]
    [Limit(0F, 3.40282347E+38F, 1F)]
    [EditorDisplay("Rigid Body", null)]
    [Unmanaged]
    public float AngularDamping { get; set; }
    Property Value
    System.Single

    CenterOfMass

    Gets the center of the mass in the local space.

    Declaration
    [Unmanaged]
    public Vector3 CenterOfMass { get; }
    Property Value
    Vector3

    CenterOfMassOffset

    Gets or sets the user specified offset for the center of mass of this object, from the calculated location.

    Declaration
    [EditorOrder(140)]
    [EditorDisplay("Rigid Body", "Center Of Mass Offset")]
    [Unmanaged]
    public Float3 CenterOfMassOffset { get; set; }
    Property Value
    Float3

    Constraints

    Gets or sets the object movement constraint flags that define degrees of freedom are allowed for the simulation of object.

    Declaration
    [EditorOrder(150)]
    [EditorDisplay("Rigid Body", null)]
    [Unmanaged]
    public RigidbodyConstraints Constraints { get; set; }
    Property Value
    RigidbodyConstraints

    EnableGravity

    If object should have the force of gravity applied.

    Declaration
    [EditorOrder(40)]
    [EditorDisplay("Rigid Body", null)]
    [Unmanaged]
    public bool EnableGravity { get; set; }
    Property Value
    System.Boolean

    EnableSimulation

    If true simulation and collisions detection will be enabled for the rigidbody.

    Declaration
    [EditorOrder(20)]
    [EditorDisplay("Rigid Body", null)]
    [Unmanaged]
    public bool EnableSimulation { get; set; }
    Property Value
    System.Boolean

    IsKinematic

    Enables kinematic mode for the rigidbody. Kinematic rigidbodies are special dynamic actors that are not influenced by forces(such as gravity), and have no momentum. They are considered to have infinite mass and can push regular dynamic actors out of the way. Kinematics will not collide with static or other kinematic objects but are great for moving platforms or characters, where direct motion control is desired.

    Declaration
    [EditorOrder(10)]
    [EditorDisplay("Rigid Body", null)]
    [Unmanaged]
    public bool IsKinematic { get; set; }
    Property Value
    System.Boolean

    IsSleeping

    Determines whether this rigidbody is sleeping.

    Declaration
    [Unmanaged]
    public bool IsSleeping { get; }
    Property Value
    System.Boolean

    LinearDamping

    Gets or sets the 'drag' force added to reduce linear movement. Linear damping can be used to slow down an object. The higher the drag the more the object slows down.

    Declaration
    [EditorOrder(60)]
    [Limit(0F, 3.40282347E+38F, 1F)]
    [EditorDisplay("Rigid Body", null)]
    [Unmanaged]
    public float LinearDamping { get; set; }
    Property Value
    System.Single

    Mass

    Gets or sets the mass value measured in kilograms (use override value only if OverrideMass is checked).

    Declaration
    [EditorOrder(110)]
    [Limit(0F, 3.40282347E+38F, 1F)]
    [EditorDisplay("Rigid Body", null)]
    [ValueCategory]
    [Unmanaged]
    public float Mass { get; set; }
    Property Value
    System.Single

    MassScale

    Gets or sets the per-instance scaling of the mass.

    Declaration
    [EditorOrder(120)]
    [Limit(0.001F, 100F, 1F)]
    [EditorDisplay("Rigid Body", null)]
    [Unmanaged]
    public float MassScale { get; set; }
    Property Value
    System.Single

    MaxAngularVelocity

    Gets or sets the maximum angular velocity that a simulated object can achieve. The angular velocity of rigidbodies is clamped to MaxAngularVelocity to avoid numerical instability with fast rotating bodies. Because this may prevent intentional fast rotations on objects such as wheels, you can override this value per rigidbody.

    Declaration
    [EditorOrder(90)]
    [Limit(0F, 3.40282347E+38F, 1F)]
    [EditorDisplay("Rigid Body", null)]
    [Unmanaged]
    public float MaxAngularVelocity { get; set; }
    Property Value
    System.Single

    StartAwake

    If object should start awake, or if it should initially be sleeping.

    Declaration
    [EditorOrder(50)]
    [EditorDisplay("Rigid Body", null)]
    [Unmanaged]
    public bool StartAwake { get; set; }
    Property Value
    System.Boolean

    UpdateMassWhenScaleChanges

    If true, it will update mass when actor scale changes.

    Declaration
    [EditorOrder(130)]
    [EditorDisplay("Rigid Body", null)]
    [Unmanaged]
    public bool UpdateMassWhenScaleChanges { get; set; }
    Property Value
    System.Boolean

    UseCCD

    If true Continuous Collision Detection (CCD) will be used for this component.

    Declaration
    [EditorOrder(30)]
    [EditorDisplay("Rigid Body", "Use CCD")]
    [Unmanaged]
    public bool UseCCD { get; set; }
    Property Value
    System.Boolean

    Methods

    AddForce(Vector3, ForceMode)

    Applies a force (or impulse) defined in the world space to the rigidbody at its center of mass.

    Declaration
    [Unmanaged]
    public void AddForce(Vector3 force, ForceMode mode)
    Parameters
    Vector3 force

    The force/impulse to apply defined in the world space.

    ForceMode mode

    The mode to use when applying the force/impulse.

    Remarks

    This will not induce any torque

    ForceMode determines if the force is to be conventional or impulsive.

    Each actor has an acceleration and a velocity change accumulator which are directly modified using the modes ForceMode.Acceleration and ForceMode.VelocityChange respectively. The modes ForceMode.Force and ForceMode.Impulse also modify these same accumulators and are just short hand for multiplying the vector parameter by inverse mass and then using ForceMode.Acceleration and ForceMode.VelocityChange respectively.

    AddForceAtPosition(Vector3, Vector3, ForceMode)

    Applies a force (or impulse) defined in the world space to the rigidbody at given position in the world space.

    Declaration
    [Unmanaged]
    public void AddForceAtPosition(Vector3 force, Vector3 position, ForceMode mode)
    Parameters
    Vector3 force

    The force/impulse to apply defined in the world space.

    Vector3 position

    The position of the force/impulse in the world space.

    ForceMode mode

    The mode to use when applying the force/impulse.

    Remarks

    Also applies appropriate amount of torque

    ForceMode determines if the force is to be conventional or impulsive.

    Each actor has an acceleration and a velocity change accumulator which are directly modified using the modes ForceMode.Acceleration and ForceMode.VelocityChange respectively. The modes ForceMode.Force and ForceMode.Impulse also modify these same accumulators and are just short hand for multiplying the vector parameter by inverse mass and then using ForceMode.Acceleration and ForceMode.VelocityChange respectively.

    AddRelativeForce(Vector3, ForceMode)

    Applies a force (or impulse) defined in the local space of the rigidbody (relative to its coordinate system) at its center of mass.

    Declaration
    [Unmanaged]
    public void AddRelativeForce(Vector3 force, ForceMode mode)
    Parameters
    Vector3 force

    The force/impulse to apply defined in the local space.

    ForceMode mode

    The mode to use when applying the force/impulse.

    Remarks

    This will not induce any torque

    ForceMode determines if the force is to be conventional or impulsive.

    Each actor has an acceleration and a velocity change accumulator which are directly modified using the modes ForceMode.Acceleration and ForceMode.VelocityChange respectively. The modes ForceMode.Force and ForceMode.Impulse also modify these same accumulators and are just short hand for multiplying the vector parameter by inverse mass and then using ForceMode.Acceleration and ForceMode.VelocityChange respectively.

    AddRelativeTorque(Vector3, ForceMode)

    Applies an impulsive torque defined in the local space of the rigidbody (relative to its coordinate system).

    Declaration
    [Unmanaged]
    public void AddRelativeTorque(Vector3 torque, ForceMode mode)
    Parameters
    Vector3 torque

    The torque to apply defined in the local space.

    ForceMode mode

    The mode to use when applying the force/impulse.

    Remarks

    ForceMode determines if the force is to be conventional or impulsive.

    Each actor has an angular acceleration and an angular velocity change accumulator which are directly modified using the modes ForceMode.Acceleration and ForceMode.VelocityChange respectively.The modes ForceMode.Force and ForceMode.Impulse also modify these same accumulators and are just short hand for multiplying the vector parameter by inverse inertia and then using ForceMode.Acceleration and ForceMode.VelocityChange respectively.

    AddTorque(Vector3, ForceMode)

    Applies an impulsive torque defined in the world space to the rigidbody.

    Declaration
    [Unmanaged]
    public void AddTorque(Vector3 torque, ForceMode mode)
    Parameters
    Vector3 torque

    The torque to apply defined in the world space.

    ForceMode mode

    The mode to use when applying the force/impulse.

    Remarks

    ForceMode determines if the force is to be conventional or impulsive.

    Each actor has an angular acceleration and an angular velocity change accumulator which are directly modified using the modes ForceMode.Acceleration and ForceMode.VelocityChange respectively.The modes ForceMode.Force and ForceMode.Impulse also modify these same accumulators and are just short hand for multiplying the vector parameter by inverse inertia and then using ForceMode.Acceleration and ForceMode.VelocityChange respectively.

    ClosestPoint(Vector3, out Vector3)

    Gets a point on one of the colliders attached to the attached that is closest to a given location. Can be used to find a hit location or position to apply explosion force or any other special effects.

    Declaration
    [Unmanaged]
    public void ClosestPoint(Vector3 position, out Vector3 result)
    Parameters
    Vector3 position

    The position to find the closest point to it.

    Vector3 result

    The result point on the rigidbody shape that is closest to the specified location.

    SetSolverIterationCounts(Int32, Int32)

    Sets the solver iteration counts for the rigidbody.

    Declaration
    [Unmanaged]
    public void SetSolverIterationCounts(int minPositionIters, int minVelocityIters)
    Parameters
    System.Int32 minPositionIters

    The minimum number of position iterations the solver should perform for this body.

    System.Int32 minVelocityIters

    The minimum number of velocity iterations the solver should perform for this body.

    Remarks

    The solver iteration count determines how accurately joints and contacts are resolved. If you are having trouble with jointed bodies oscillating and behaving erratically, then setting a higher position iteration count may improve their stability.

    If intersecting bodies are being depenetrated too violently, increase the number of velocity iterations. More velocity iterations will drive the relative exit velocity of the intersecting objects closer to the correct value given the restitution.

    Default: 4 position iterations, 1 velocity iteration.

    Sleep()

    Forces a rigidbody to sleep (for at least one frame).

    Declaration
    [Unmanaged]
    public void Sleep()

    UpdateMass()

    Updates the actor's mass (auto calculated mass from density and inertia tensor or overriden value).

    Declaration
    [Unmanaged]
    public void UpdateMass()

    WakeUp()

    Forces a rigidbody to wake up.

    Declaration
    [Unmanaged]
    public void WakeUp()

    Events

    CollisionEnter

    Occurs when a collision start gets registered for this rigidbody (it collides with something).

    Declaration
    [Unmanaged]
    public event Action<Collision> CollisionEnter
    Event Type
    System.Action<Collision>

    CollisionExit

    Occurs when a collision end gets registered for this rigidbody (it ends colliding with something).

    Declaration
    [Unmanaged]
    public event Action<Collision> CollisionExit
    Event Type
    System.Action<Collision>

    TriggerEnter

    Occurs when this rigidbody trigger touching start gets registered for this collider (the other collider enters it and triggers the event).

    Declaration
    [Unmanaged]
    public event Action<PhysicsColliderActor> TriggerEnter
    Event Type
    System.Action<PhysicsColliderActor>

    TriggerExit

    Occurs when this rigidbody trigger touching end gets registered for this collider (the other collider enters it and triggers the event).

    Declaration
    [Unmanaged]
    public event Action<PhysicsColliderActor> TriggerExit
    Event Type
    System.Action<PhysicsColliderActor>

    Extension Methods

    Extensions.ReflectiveCompare<T>(T, T)
    Extensions.DeepClone<T>(T)
    Extensions.RawClone<T>(T)

    See Also

    Actor
    In This Article
    Back to top Copyright © 2012-2024 Wojciech Figat