- Home /
Check for collisions with script outside of object with collider
In the game I'm making I have what are basically short quests. These quests are initiated when the player steps into the BeginQuestCollider for the specific quest, and ended when the player completes the quest, let's say for an example it is completed by putting a box on top of another box.
My game is made up of many of these quests, so how I want to do it is have an game object that is there only to hold all of my quests and check for them starting / being completed. So, for the quest I have described above, I have the script for the quest that has public fields where I can drag and drop the colliders of the different parts of the quest into the script, so it knows which collider serves as its begin quest collider, which collider is the box's the player will be moving, and which collider it is the player has to move the box into.
The problem here is I cannot find a way to check these colliders against each other from the script. If I were to separate this quest so I could use the OnTriggerEnter function, I would have to have a minimum of two instances of the script: one on the start quest object, and one on the object where the player has to drop the box to be checking for the box. I would much rather have the quest outside of all of that, sitting back in its QuestManager object along with the scripts for all of the other short quests, checking the colliders against the colliders that I drop into its public fields. Is there a way to do this?
Thanks a bunch!
Forgive me if this approach is naive/not what you wanted, but could you just call OnTriggerEnter on the script for your Quest$$anonymous$$anager from a script attached to the place where you're dropping the box?
void OnTriggerEnter(Collider other) { Quest$$anonymous$$anager.Instance.OnTriggerEnter(other); }
It sounds like it'd be easier to use a notification system where the box_drop_location notifies the Quest$$anonymous$$anager rather than the Quest$$anonymous$$anager keeping a reference to every box_drop_location.
It seems like I may have to do this. I just didn't want to have a script on every part of every quest, as the number of very tiny scripts that do almost nothing will be enormous.
If you do go that route, you may have an easier time of it by adding those scripts through code with calls to AddComponent(), whether at runtime or in an editor script.
Your answer
![](https://koobas.hobune.stream/wayback/20220613071049im_/https://answers.unity.com/themes/thub/images/avi.jpg)