- Edited
I am trying to display how many collisions that a raycast meets. I have not been able to find any pointers yet online.
I am trying to display how many collisions that a raycast meets. I have not been able to find any pointers yet online.
A raycast will only give you the first (closest) object that it intersects. To get more you can use a loop where you ignore the previous collider on each iteration. Something like this should work:
var ray = $RayCast
for i in range(10): # get up to 10 objects
ray.force_raycast_update()
if !ray.is_colliding():
print("no more collisions")
break
var collider = ray.get_collider()
print("colliding with", collider)
ray.add_exception(collider)
Note: please consider this pseudo code only to provide the basic idea - it's completely untested and errors are quite likely.
Thank you =)