I’m making a tile based game where the board is mapped out in the editor, and collisions are used with tiles and units to check which tiles are next to each other and which tile a unit belongs on top of. This only happens at the start, of course, because every tile stores its neighbors and resident unit. I remove the rigid bodies and colliders used for collisions in Start.
1 out of 5 times or so (only when using Application.loadLevel()), though, the collisions didn’t seem to run. After some messing around, it seems like collisions aren’t guaranteed to be run before Start() is called, even though it seemed to most of the time.
So there are a few ways I can see solving this, but I’m not sure if I can do it in Unity:
- Set some kind of parameter that forces collisions to be checked before Start() or even Update()
- Manually check collisions against one collider or manually check collisions between two colliders using something like Collider.collide(Collider), if that exists.
- If I can’t do any of that, I’ll just do some manual raycasting and see what it hits.
Are there any other solutions?