- Home /
Question by
camtronius · Apr 19, 2014 at 02:39 AM ·
physicsnoobrtsspherecollidercontains
How to check if an object of objects is inside a spherecollider
Hi guys, I have a cylindrical object which has a sphere collider attached to it (think a tower, with a attack radius). I want to know what code I use so that the tower detects if an enemy is inside its range. Thanks guys,
Comment
See Physics.OverlapSphere(). If your enemies have Rigidbodies, you can use OnCollisionEnter().
Best Answer
Answer by EvilTak · Apr 19, 2014 at 09:58 AM
You can make the sphere collider a trigger and use OnTriggerEnter() to detect and recognize any object which has entered the attack radius (in this case the sphere collider). Make sure that the objects to be detected have a collider.