Check collsion of objects in another script
Hey, in my game I have synergy attacks, so i'm thinking about having a synergy manager where i add all my scripts. Then I want a script that checks for attacks colliding. Is it possible? Haven't found anything yet. Some code would help, so i will get a grasp about it.
Answer by Owen-Reynolds · Oct 27, 2016 at 02:39 PM
In Unity, collision events are only sent to the object involved in the collision, through the OnCollision function. There's no way to tell the engine to change that.
What you can do is write little stubs to redirect (I'm sure I'm misusing delegates here):
public someBase.collisionHandler_t myCEhandler; // someone sets this
void OnCollisionEnter(Collision c1) { myCEhandler(c1); }
But that's for built-in physics collision events. You can hand-check collision in any piece of code, for any colliders using overlapSphere/box, capsulecasts.
Your answer
![](https://koobas.hobune.stream/wayback/20220612095510im_/https://answers.unity.com/themes/thub/images/avi.jpg)
Follow this Question
Related Questions
Can a Trigger object utilize the OnTriggerEnter() Function? 2 Answers
Objects not colliding 1 Answer
Code is acting different depending on call 2 Answers
Collision is not working with some Collider2d 1 Answer
Player trigger on platform with prefab 0 Answers