Hierarchy

  • __type<typeof Behavior, this> & Behavior<Component<any, ConstructorProps>, this>
    • RigidBodyBehavior

Accessors

  • get disposed(): boolean
  • Gets the disposed status of the entity.

    Returns boolean

    The disposed status.

Constructors

Methods

  • Returns [[number, number, number], [number, number, number, number]]

  • Parameters

    • position: Vector3
    • quaternion: Quaternion
    • scene: Scene

    Returns void

  • Applies a force to a physics body at a given location.

    Parameters

    • force: Vector3 | [number, number, number]

      The force vector to apply.

    • Optionallocation: Vector3 | [number, number, number]

      The location in world space to apply the impulse.

      This method is useful for applying a force to a physics body at a given location. This can be used to simulate physical forces such as explosions, collisions, and gravity.

      If location is not provided, the force will be applied to the center of the body.

    Returns void

  • Applies an impulse to a physics body at a given location.

    Parameters

    • impulse: Vector3 | [number, number, number]

      The impulse vector to apply.

    • Optionallocation: Vector3 | [number, number, number]

      The location in world space to apply the impulse.

      This method is useful for applying an impulse to a physics body at a given location. This can be used to simulate physical forces such as explosions, collisions, and gravity.

      If location is not provided, the impulse will be applied to the center of the body.

    Returns void

  • Parameters

    • component: Component<any, ConstructorProps>

    Returns void

  • Returns any

  • Destroy this entity, cleaning up any resources that it has created and handler functions or callbacks it has registered.

    The base class implementation automatically unregisters any handler functions registered using register(...).

    Override this function in your own components and behaviors to clean up any resources you have created. If you do override this function, end it with:

    return super.dispose();
    

    This ensures that the dispose implementation of the parent class runs.

    Returns never

    The result of a call to super.dispose()

  • Gets the angular damping of a physics body.

    Returns number

    The angular damping of the body.

    This function is useful for retrieving the angular damping of a physics body, which is used to control the rotational motion of the body. The angular damping is a value between 0 and 1, where 0 is no damping and 1 is full damping.

  • Gets the gravity factor of a body.

    Returns number

    The gravity factor of the body.

  • Gets the linear damping of a physics body.

    Returns number

    The linear damping of the body.

  • Gets the linear velocity of a physics body and stores it in a given vector.

    Parameters

    • linVel: Vector3

    Returns void

  • Gets the mass properties of a physics body.

    Returns PhysicsMassProperties

    The mass properties of the body.

  • Get the instance of the ZComponent that constructed this entity.

    If you pass the class of a ZComponent as the type parameter, this function will ensure that it returns an instance of that ZComponent. If this component or behavior was constructed by a different ZComponent class, or by a different entity altogether, the function with throw an error.

    Type Parameters

    • T extends ZComponent<any, T> = ZComponent<any>

    Parameters

    • Optionaltype: ConstructorForComponent<T>

      The ZComponent class that you are expecting to receive

    Returns T

    The instance of the ZComponent that constructed this component or behavior

  • Register a function to be called when an Event is fired, or an Observable's value changes. The function will only be bound to the underlying Event or Observable while this entity is enabled.

    Using this function, rather than attaching your handler directly to the Event or Observable, ensures your handler is automatically released when this entity is disposed.

    Type Parameters

    • Args extends any[]

    Parameters

    • evt: Event<Args>

      The Event or Observable to listen to

    • fn: ((...args: Args) => void)

      A function that will be called when the event fires, or the Observable value changes

        • (...args): void
        • Parameters

          Returns void

    • Optionalpriority: number

    Returns any

  • Type Parameters

    • Args extends any[]

    Parameters

    Returns any

  • Type Parameters

    • Type

    Parameters

    • observable: Observable<Type, never>
    • fn: ((v: Type) => void)
        • (v): void
        • Parameters

          Returns void

    • Optionalpriority: number

    Returns any

  • Type Parameters

    • Type

    Parameters

    Returns any

  • Sets the angular damping of a physics body.

    Parameters

    • damping: number

      The angular damping value to set.

      This function is useful for controlling the angular velocity of a physics body. By setting the angular damping, the body's angular velocity will be reduced over time, allowing for more realistic physics simulations.

    Returns void

  • Sets the angular velocity of a physics body.

    Parameters

    • angVel: Vector3 | [number, number, number]

      The angular velocity vector to set.

    Returns void

  • Sets the gravity factor of a body.

    Parameters

    • factor: number

      The gravity factor to set.

    Returns void

  • Sets the linear damping of the given body.

    Parameters

    • damping: number

      The linear damping to set.

      This method is useful for controlling the linear damping of a body in a physics engine. Linear damping is a force that opposes the motion of the body, and is proportional to the velocity of the body. This method allows the user to set the linear damping of a body, which can be used to control the motion of the body.

    Returns void

  • Sets the linear velocity of a physics body.

    Parameters

    • linVel: Vector3 | [number, number, number]

      The linear velocity vector to set.

    Returns void

  • Sets the motion type of a physics body. Can be STATIC, DYNAMIC, or KINEMATIC.

    Parameters

    Returns void

  • Unregisters a function that was previously registered to an Event or Observable.

    Type Parameters

    • Args extends any[]

    Parameters

    • evt: Event<Args>

      The Event or Observable

    • fn: ((...args: Args) => void)

      The function that was passed in the call to register

        • (...args): void
        • Parameters

          Returns void

    Returns any

  • Type Parameters

    • Type

    Parameters

    • observable: Observable<Type, never>
    • fn: ((v: Type) => void)
        • (v): void
        • Parameters

          Returns void

    Returns any

Properties - Behavior

enabled: Observable<boolean, never>

If false, this entity and its children will no longer participate in the experience.

Note - to read this value, you may wish to use enabledResolved which will be false if this entity, or any of its parents, have enabled set to false.

The precise implications of enabled being false will vary between entities, but in general disabled entities:

  • should not emit any events,
  • should not take any action, e.g. navigate the user to a different page,
  • should not perform any network communication,
  • should not make changes to other behaviors or components in the experience,
  • should minimise any runtime performance cost (e.g. detach from any frame handlers).

true

10

Properties - Collider Properties

bounciness: Observable<number, never> = ...

Sets the bounciness of the physics material.z

The bounciness is a factor which describes, the amount of energy that is retained after a collision, which should be a number between 0 and 1..

A bounciness of 0 means that no energy is retained and the objects will not bounce off each other, while a bounciness of 1 means that all energy is retained and the objects will bounce.

Note, though, due that due to the simulation implementation, an object with a bounciness of 1 may still lose energy over time.

If not provided, a default value of 0 will be used.

0

proportion

friction: Observable<number, never> = ...

Sets the friction used by this material

The friction determines how much an object will slow down when it is in contact with another object. This is important for simulating realistic physics, such as when an object slides across a surface.

If not provided, a default value of 0.5 will be used.

0.5

proportion

Properties - Damping

angularDamping: Observable<number, never> = ...

Sets the angular damping of a physics body.

This function is useful for controlling the angular velocity of a physics body. By setting the angular damping, the body's angular velocity will be reduced over time, allowing for more realistic physics simulations.

0

24

linearDamping: Observable<number, never> = ...

Sets the linear damping of the given body.

This method is useful for controlling the linear damping of a body in a physics engine. Linear damping is a force that opposes the motion of the body, and is proportional to the velocity of the body. This method allows the user to set the linear damping of a body, which can be used to control the motion of the body.

0

24

Properties - Density

density: Observable<number, never> = ...

Sets the density of a physics shape.

0

24

Properties - Grab

grabbable: boolean = false

When true, the object can be picked up using the RigidbodyGrabber component.

The rigid body must have a DYNAMIC motion type to be grabbable.

false

24

Properties - Gravity

gravityFactor: Observable<number, never> = ...

Sets the gravity factor of a body.

1

23

Properties - Mass

centerOfMass: Observable<undefined | [number, number, number], never> = ...

Defaults to the center of the rigid body. The center of mass, in local space. This is The point the body will rotate around when applying an angular velocity.

If not provided, the physics engine will compute an appropriate value.

22

[0,0,0]

inertia: Observable<undefined | [number, number, number], never> = ...

The principal moments of inertia of this object for a unit mass. This determines how easy it is for the body to rotate. A value of zero on any axis will be used as infinite interia about that axis.

If not provided, the physics engine will compute an appropriate value.

22

[0,0,0]

inertiaOrientation: Observable<undefined | [number, number, number, number], never> = ...

The rotation rotating from inertia major axis space to parent space (i.e., the rotation which, when applied to the 3x3 inertia tensor causes the inertia tensor to become a diagonal matrix). This determines how the values of inertia are aligned with the parent object.

If not provided, the physics engine will compute an appropriate value.

22

[0,0,0,0]

mass: Observable<undefined | number, never> = ...

The total mass of this object, in kilograms. This affects how easy it is to move the body. A value of zero will be used as an infinite mass.

If not provided, the physics engine will compute an appropriate value.

22

0

Properties - Other

_dirtyFlags: {
    angularDamping: boolean;
    density: boolean;
    gravityFactor: boolean;
    linearDamping: boolean;
    massProperties: boolean;
    motionType: boolean;
    targetTransform: boolean;
    transforms: boolean;
} = ...
bodyId: HP_ShapeId

Identifier for the physics body associated with this collider in the physics world.

colliders: Collider[] = []
containerShapeID: HP_ShapeId

Identifier for the shape used in the physics engine.

contextManager: ContextManager
enabledResolved: Observable<boolean, never>

This will have value false if this entity, or any of its parents, have enabled set to false.

To change the enabled status of this entity, use the enabled property instead.

The precise implications of enabled being false will vary between entities, but in general disabled entities:

  • should not emit any events,
  • should not take any action, e.g. navigate the user to a different page,
  • should not perform any network communication,
  • should not make changes to other behaviors or components in the experience,
  • should minimise any runtime performance cost.

Disabled entities will typically remain visible (if they have a visible appearance).

instance: Component<any, ConstructorProps>
isRigidBody: true = ...
motionType: Observable<MotionType, never> = ...

Sets the motion type of a physics body.

  • Static: The body is not affected by forces or collisions. It remains fixed in place unless moved manually. Use this for objects that should not move or interact with other physics objects, such as walls or stationary obstacles.

  • Dynamic: The body is affected by forces and collisions. It responds to gravity, collisions, and other physical interactions. Use this for objects that should have realistic physics behavior, such as falling boxes, projectiles, or characters.

  • Kinematic: The body is not affected by forces, but can be moved by setting its transform. It does not respond to collisions. Use this for objects that need to be animated or moved programmatically, such as moving platforms or camera-controlled objects. Note: Kinematic objects can suffer from teleportation issues and may clip through other objects if animated too quickly.

Dynamic

onCollision: Event<[IPhysicsCollisionEvent]> = ...
onDispose: Event<[]>

An event that is fired as the last act of this entity being destroyed.

onGrab: Event<[RigidbodyGrabber]> = ...

Emit when a RigidbodyGrabber grabs the object.

onGrabInRange: Event<[RigidbodyGrabber]> = ...

Emitted when a RigidbodyGrabber is within range of the object.

onGrabOutOfRange: Event<[RigidbodyGrabber]> = ...

Emitted when a RigidbodyGrabber is within range of the object.

onRelease: Event<[RigidbodyGrabber]> = ...

Emitted when a RigidbodyGrabber releases the object.

physicsContex: HavokContext
propsWorldTransform: Observable<Matrix4, never> = ...
ready: Observable<boolean, never> = ...

Emitted when the rigid body is ready to be used.

reportCollisions: boolean
targetTransform: Observable<null | [[number, number, number], [number, number, number, number]], never> = ...