Implements

Constructors

Properties

debugRenderColliders: boolean = false

Enable to render collider shapes

debugRenderRaycasts: boolean = false

Enable to visualize raycasts in the scene with gizmos

Accessors

  • get gravity(): Vec3
  • Returns Vec3

  • set gravity(value): void
  • Parameters

    • value: Vec3

    Returns void

  • get isUpdating(): boolean
  • Returns boolean

  • get world(): undefined | World
  • Get access to the rapier world

    Returns undefined | World

Methods

  • The joint prevents any relative movement between two rigid-bodies, except for relative rotations along one axis. This is typically used to simulate wheels, fans, etc. They are characterized by one local anchor as well as one local axis on each rigid-body.

    Parameters

    • body1: IRigidbody
    • body2: IRigidbody
    • anchor: {
          x: number;
          y: number;
          z: number;
      }
      • x: number
      • y: number
      • z: number
    • axis: {
          x: number;
          y: number;
          z: number;
      }
      • x: number
      • y: number
      • z: number

    Returns void

  • Parameters

    Returns void

  • clear all possibly cached data (e.g. mesh data when creating scaled mesh colliders)

    Returns void

  • Fast raycast against physics colliders

    Parameters

    • Optionalorigin: Vec3 | Vec2

      ray origin in screen or worldspace

    • Optionaldirection: Vec3

      ray direction in worldspace

    • Optionaloptions: {
          filterGroups?: number;
          filterPredicate?: ((c: ICollider) => boolean);
          maxDistance?: number;
          queryFilterFlags?: QueryFilterFlags;
          solid?: boolean;
          useIgnoreRaycastLayer?: boolean;
      }

      additional options

      • OptionalfilterGroups?: number
      • OptionalfilterPredicate?: ((c: ICollider) => boolean)

        Return false to ignore this collider

          • (c): boolean
          • Parameters

            Returns boolean

      • OptionalmaxDistance?: number
      • OptionalqueryFilterFlags?: QueryFilterFlags
      • Optionalsolid?: boolean

        True if you want to also hit objects when the raycast starts from inside a collider

      • OptionaluseIgnoreRaycastLayer?: boolean

        When enabled the hit object's layer will be tested. If layer 2 is enabled the object will be ignored (Layer 2 == IgnoreRaycast) If not set the raycast will ignore objects in the IgnoreRaycast layer (default: true)

        undefined
        

    Returns null | {
        collider: ICollider;
        point: Vector3;
    }

  • raycast that also gets the normal vector. If you don't need it use raycast()

    Parameters

    • Optionalorigin: Vec3 | Vec2
    • Optionaldirection: Vec3
    • Optionaloptions: {
          filterGroups?: number;
          filterPredicate?: ((c: ICollider) => boolean);
          maxDistance?: number;
          queryFilterFlags?: QueryFilterFlags;
          solid?: boolean;
          useIgnoreRaycastLayer?: boolean;
      }
      • OptionalfilterGroups?: number
      • OptionalfilterPredicate?: ((c: ICollider) => boolean)

        Return false to ignore this collider

          • (c): boolean
          • Parameters

            Returns boolean

      • OptionalmaxDistance?: number
      • OptionalqueryFilterFlags?: QueryFilterFlags
      • Optionalsolid?: boolean

        True if you want to also hit objects when the raycast starts from inside a collider

      • OptionaluseIgnoreRaycastLayer?: boolean

        When enabled the hit object's layer will be tested. If layer 2 is enabled the object will be ignored (Layer 2 == IgnoreRaycast) If not set the raycast will ignore objects in the IgnoreRaycast layer (default: true)

        undefined
        

    Returns null | {
        collider: ICollider;
        normal: Vector3;
        point: Vector3;
    }

  • Precice sphere overlap detection using rapier against colliders

    Parameters

    • point: Vector3

      center of the sphere in worldspace

    • radius: number

      radius of the sphere

    Returns SphereOverlapResult[]

    array of colliders that overlap with the sphere. Note: they currently only contain the collider and the gameobject

  • Parameters

    • Optionaldt: number

    Returns void