I would like to implement an AoE system, like in Wildstar, Lol, Wow…, but even though I feel it is in like half the games, I can’t find any information about how to do it ! ><"
I want to have a shape on the ground (preferably that follows the ground’s variations), let’s say a square, and that detects whenever an enemy enters that said square.
The only way I have found is it use box colliders, but surely there is more efficient to detect what is basically 2D collisions than an box collider…
If you only need the collision check to occur once you can use a box or sphere cast. It effectively functions like a collider but only for a single frame and without having to create a game object and assign a collider.
That sounds like a pretty good idea, thanks !
Two questions : if I understand correctly, that’s still checking for 3D collisions, right ? Isn’t there a less expensive way that would only check on a 2D plane (the ground) ?
What if an AoE is neither a circle nor a square ? Like I have a star-shaped AoE and I want to know what enemy is inside ?
Unity has two separate physics systems. One for handling 2D and one for handling 3D. To my knowledge they cannot interact with each other. If the targets have 3D colliders on them then you need to use 3D casts or colliders to detect them.
Besides I wouldn’t worry about performance. All of the basic shape colliders and casts are extremely efficient with all sorts of internal optimizations. You wouldn’t see a meaningful performance difference unless you were using hundreds of them if not thousands.
Some combination of multiple casts and checking transforms. You could use a MeshCollider but it’s far more expensive than any other form of collider and more expensive than using a combination of techniques.