Options
All
  • Public
  • Public/Protected
  • All
Menu

Namespace RayCast

Raycast related method and properties.

Index

Functions

  • Adds an item to the raycast filter.

    Items added to the filter will not be traceable.

    Parameters

    • item: BaseItem

      item to add to the filter.

    Returns void

  • Casts a ray from origin towards direction. The ray length is infinite.

    If the ray hits an item it returns a RayCast.Result, otherwise null.

    Example

    //Casts a ray from the camera position towards the camera direction every frame
    Time.scheduleRepeating(() => {
    let rayCastHit = RayCast.cast(Camera.transform.position, Camera.transform.forward)

    if (rayCastHit) {
    Debug.log(`Ray hit item: ${rayCastHit.item.name}`)
    } else {
    Debug.log("Ray hit no item.")
    }
    })

    Parameters

    • origin: Vector3

      starting point of the ray.

    • direction: Vector3

      direction of the ray.

    Returns Result

    hit result. Returns null when no item is hit.

  • Removes an item from the raycast filter.

    Parameters

    • item: BaseItem

      item to remove from the filter.

    Returns void