ray_cast.cast method
Casts a ray from origin
towards direction
. The ray length is infinite.
If the ray hits an item it returns a Result, otherwise null
.
Example
# Casts a ray from the camera position towards the camera direction every frame
def ray_cast_action(dt):
hit_result = ray_cast.cast(camera.transform.position, camera.transform.forward)
if hit_result is not None:
print('Ray hit item: {}'.format(hit_result.item.name))
else:
print('Ray hit no item.')
time.schedule_repeating(ray_cast_action)
Parameters
Returns
hit result. Returns null
when no item is hit.