- Home /
BoxCollider vs. RaycastAll
Hi,
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 !
How often is the counting done? Unless its done every frame I do nt think you will notice much performance difference.
Do what works best, then worry about performance when/if needed.
Answer by Zuwolf · Jun 24, 2013 at 09:20 AM
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.
Answer by MountDoomTeam · Jun 24, 2013 at 10:42 AM
detect position in space = compare object.transform.position with other positions detect collisions with other objects = overlap sphere, spherecast, ontrigger, etc.
Your answer
Follow this Question
Related Questions
How can I test if there is a collision near my rigidbody? 2 Answers
Slant Physics Raycast Implementation 0 Answers
How to prevent a sphere from jumping? 0 Answers