I am scripting a random map generator similar to the ones in dungeon crawlers. The way I was hoping to detect if doorways to one room connected properly to the other doorways in the other rooms was through box colliders, however the functions in the documentation, specifically OnTriggerEnter, is called long after Awake() has been executed, is there any other way to detect collision while still in the Awake() stages without having to write a new collision detection function? Or perhaps there is an easier way I may be overlooking?
Have you checked the sequence that your scripts are loaded?
Here is a quick overview of the system:
- I have one GameObject with the script to generate the map
- The actual map generating is on the Awake() function on this GameObject’s script
- In the Awake() function, I need a way to detect collisions among the prefabs (rooms) I instantiate
OnTriggerEnter doesn’t cut it because the commands on the object I just instantiated are executed after Awake() is finished, and there are a lot of checks that depend on some of the commands in my OnTriggerEnter function.
This seemed helpful, http://forum.unity3d.com/threads/26657-Collision-detection-Empty-game-object?highlight=collision+detector, although so far whenever I seem to successfully get the engine to check for collisions on Awake(), Unity crashes…
I gave up on having the map generated at Awake(), unless someone has any other ideas on how to check for collisions during Awake(), I am moving the map generation to Update() and delay spawning the player until it is done…