BoxCollider vs. RaycastAll


I have to make a choice between BoxCollider and RaycastAll.
I have to check if an object is in a certain part of a space.
For the moment I do multiple RaycastAll, about 50, and I retrieve all the data I want. But is it a good performance choice ?

With RaycastAll I can have the distance between the Raycast and the object and it seems to avoid High speed objects. And I don’t have to create GameObjects to hold BoxCollider.

But for me, BoxCollider are better for performance but I can’t have the distance and I would have to create useless GameObjects, about 50.

What would be the best solution ? What are the cost of those technics ?

Thanks a lot !

Raycasting is a good way to detect/foresee objects/collisions, but in your case to detect an object in a specific space a collider with Trigger is less greedy and well-adjust to your needs.
I can’t tell you what are the cost because i’m not an Unity expert but you can do tests with a lot of objects and you’ll see who’s be more powerful.

detect position in space = compare object.transform.position with other positions
detect collisions with other objects = overlap sphere, spherecast, ontrigger, etc.