How to achieve Raycast (MaxIntersection) in DOTS?

Hello everyone,

Is there a method to achieve MaxIntersection?

I did a system that moves the player when clicking on the ground using Raycast and custom physics tag, when I’m working on picking system that lets the player pick items from ground when click on it, but the Raycast detects both the item and the ground. How can I make the Ray only detect the item when click on it. Or how to make the Ray only intersect with only one object?

Thanks in advance.

Sounds like you are using
CastRay(RaycastInput, ref NativeList) instead of
CastRay(RaycastInput, out RaycastHit)

The first one is for getting all hits while the second only returns the closest hit.

1 Like

Thank you so much you saved me. :slight_smile: