Preparing search index...

    Class BodyComponent

    Allows Physics simulation to control SceneObject.

    Derived from ColliderComponent, attaching this to a SceneObject turns it into a dynamic rigid-body that is automatically moved by the physics simulation in response to gravity, collisions, and other forces.

    Lens Scripting Version 164

    // @input Physics.BodyComponent bodyComponent

    // Add instant impulse force upward
    script.bodyComponent.addForce(new vec3(0, 500, 0), Physics.ForceMode.Impulse);

    // Add instant impulse torque to rotate the object
    script.bodyComponent.addTorque(new vec3(0, 0, Math.PI * -25), Physics.ForceMode.Impulse);

    // Every frame, add upward force over time, relative to the object rotation
    // This is similar to a rocket boosting the object upward
    script.createEvent("UpdateEvent").bind(function() {
    script.bodyComponent.addRelativeForce(new vec3(0, 2000, 0), Physics.ForceMode.Force);
    });

    Hierarchy (View Summary)

    Index

    Properties

    angularDamping: number

    Damping applied to angular velocity, in the range 0.0 (no damping) to 1.0 (maximum damping).

    Lens Scripting Version 164

    0
    
    angularVelocity: vec3

    Angular velocity, expressed as an axis of rotation scaled by angular speed (radians/s).

    Lens Scripting Version 164

    (0, 0, 0)
    

    Expects a LevelsetColliderAsset. Contains distance field data which describes a collider's shape. A selection of default Levelset assets can be found in Resource->Add->Hairstyle Colliders

    Use ColliderComponent#shape to set the shape to a LevelsetShape

    Lens Scripting Version 152

    damping: number

    Damping applied to linear velocity, in the range 0.0 (no damping) to 1.0 (maximum damping). This produces an effect similar to drag in that it causes the object to slow down over time. It is not however physically accurate, and it doesn't take into account surface area or mass.

    Lens Scripting Version 164

    0
    
    debugDrawEnabled: boolean

    Toggle collider wire rendering for visualizing collider geometry shape and where it is placed.

    Lens Scripting Version 152

    false
    
    density: number

    Density (kg/L) of the object, used to derive mass from volume. If modified, mass changes according to shape and scale.

    Lens Scripting Version 164

    dynamic: boolean

    If enabled, the body is dynamically simulated, such that it responds to forces and collisions, nested collider/body components will be merged into compound shapes. Otherwise, it acts as a static collider, functionally equivalent to Physics.ColliderComponent.

    Lens Scripting Version 164

    true
    
    enabled: boolean

    If disabled, the Component will stop enacting its behavior.

    true
    
    filter: Physics.Filter

    Collision filter to use for this collider.

    Lens Scripting Version 183

    null
    
    fitVisual: boolean

    If enabled, the collider shape extends to fit the visual mesh, if any. Only applicable for Box and Sphere shapes.

    Lens Scripting Version 164

    true
    
    forceCompound: boolean

    Nested collider/body components may be merged into compound shapes. By default, this occurs only for dynamic bodies and not for static colliders. If forceCompound is set, this occurs for static colliders as well.

    Lens Scripting Version 169

    false
    
    intangible: boolean

    If enabled, the collider doesn't interact with the world but may still be detected with ray casts and intersection events.

    Lens Scripting Version 164

    false
    
    isBeingDestroyed: boolean

    Returns true if this Component is currently being destroyed. Becomes true as soon as destruction begins via Component#destroy or destruction of its owning SceneObject, before any OnDestroyEvent callbacks fire.

    Lens Scripting Version 364

    if (!script.isBeingDestroyed) {
    // Component is still fully alive
    }
    isEnabledInHierarchy: boolean

    Returns true if this Component, its SceneObject, and all of that SceneObjects parents are enabled.

    mass: number

    Mass (kg) of the object. If modified from this field, mass is constant irrespective of shape and scale.

    Lens Scripting Version 164

    matter: Matter

    The matter used by the collider to define its physical substance, such as friction and bounciness.

    Lens Scripting Version 169

    null
    
    onCollisionEnter: event1<CollisionEnterEventArgs, void>

    Signals when objects initially collide.

    Lens Scripting Version 152

    onCollisionExit: event1<CollisionExitEventArgs, void>

    Signals when objects stop colliding.

    Lens Scripting Version 152

    onCollisionStay: event1<CollisionStayEventArgs, void>

    Signals every frame while objects continue to collide.

    Lens Scripting Version 152

    onOverlapEnter: event1<OverlapEnterEventArgs, void>

    Signals when colliders first overlap.

    Lens Scripting Version 152

    onOverlapExit: event1<OverlapExitEventArgs, void>

    Signals when colliders stop overlapping.

    Lens Scripting Version 152

    onOverlapStay: event1<OverlapStayEventArgs, void>

    Signals every frame while colliders continue to overlap.

    Lens Scripting Version 152

    overlapFilter: Physics.Filter

    Collision filter used for overlap events.

    Lens Scripting Version 164

    null
    
    rotateSmoothFactor: number

    Smoothing spring factor, for rotation.

    Lens Scripting Version 169

    30
    
    sceneObject: SceneObject

    The SceneObject this component is on.

    shape: Shape

    The Shape object used for collision.

    Lens Scripting Version 157

    null
    
    smooth: boolean

    Smooth transform changes using a dampened spring. Useful to reduce motion noise. This only applies to the simulation and changes from outside the simulation. The SceneObject's transform is not affected. It has no effect for dynamic bodies.

    Lens Scripting Version 169

    false
    
    translateSmoothFactor: number

    Smoothing spring factor, for translation. This controls the restitution strength of the spring, so low values are smoother but lag more.

    Lens Scripting Version 169

    30
    
    uniqueIdentifier: string

    Lens Scripting Version 176

    velocity: vec3

    Linear velocity (cm/s).

    Lens Scripting Version 164

    (0, 0, 0)
    
    worldSettings: WorldSettingsAsset

    The WorldSettingsAsset used by the collider to define the physics simulation settings.

    Lens Scripting Version 169

    null
    

    Methods

    • Apply linear force at the object's center-of-mass.

      Parameters

      Returns void

      Lens Scripting Version 164

    • Apply force at a point offset from the object's origin, effectively generating torque.

      Parameters

      Returns void

      Lens Scripting Version 164

    • Add a point constraint between this body and the given collider, at the given position. target is optional. If null, it is statically constrained to the world. This is a convenience function that creates a child SceneObject with a ConstraintComponent, and sets its type, target, and constraint parameters. To fully remove the constraint, its SceneObject must be removed - not the component. Call removeConstraint() to do this.

      Parameters

      Returns ConstraintComponent

      Lens Scripting Version 164

    • Relative to local rotation, apply linear force at the object's center-of-mass.

      Parameters

      Returns void

      Lens Scripting Version 164

    • Relative to local rotation, apply force at a point offset from the object's origin, effectively generating torque.

      Parameters

      Returns void

      Lens Scripting Version 164

    • Relative to local rotation, apply torque (angular force).

      Parameters

      Returns void

      Lens Scripting Version 164

    • Apply torque (angular force).

      Parameters

      Returns void

      Lens Scripting Version 164

    • Clears all velocities and forces on a collider.

      Returns void

      Lens Scripting Version 164

    • Returns true if the object matches or derives from the passed in type.

      Parameters

      • type: string

      Returns boolean

    • Removes a constraint that was added with one of the add*Constraint() functions.

      Parameters

      Returns void

      Lens Scripting Version 164