Adds an item
to the raycast filter.
Items added to the filter will not be traceable.
item to add to the filter.
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.")
}
})
hit result. Returns null
when no item is hit.
Removes an item
from the raycast filter.
item to remove from the filter.
Raycast related method and properties.