Does OnControllerCollider have an equivalent to OnCollisionExit?

Hello everyone!

This is my first time both posting on the forums and scripting in Unity, but I have enough experience of programming in Java to at least get by.

I’m trying to test a random tile spawn function that will be running in real-time (so it’s not randomly pre-generated), and I’ll explain it briefly:

The player starts in the center tile of a tight formation of nine tiles. When the player enters a new tile, the same formation needs to be created around that tile, however it shouldn’t do so until the player leaves the center tile with a bit of a margin. Currently I have a trigger box covering the center tile and a bit of the adjacent tiles, so I know when the player is far enough away.

Now, the way I did this originally was with OnCollisionEnter, OnCollisionStay and OnCollisionExit, as I was testing it out with a rigid body cube that I had given a simple movement script. As I realized I may want a Character Controller instead, my method required me to use OnControllerColliderHit instead, and I was rather stumped at how to make that work.

So my first question is: are there any equivalent variants of OnControllerCollider that works like the three previous functions I was using?

Even better would be if I could have an OnTriggerExit (on my trigger volume over the center tile) that can call a function in my Character Controller to see what tile it is currently touching (and if the player is in the air, it’ll keep checking until the player is actually touching a tile). But is there any such function I could call?

Anyway, despite this minor setback of mine, I must say I do like Unity a lot better than I did UDK.

Thanks a lot!
// Rickard

It doesn’t seem like there are any functions like what you are looking for:

Just to be clear, the each tile has a script, and all scripts are responsible for how other tiles are generated around them?

If that’s the case, Here’s what I propose:
Make a parent object for all those tiles.
The parent is responsible for creating the tiles, but waits for a message to create.
Each tile has a sphere trigger collider, just to have collision thats equal distance from the center of all tiles - no matter what angle you come at, the radius of the sphere is the distance from the center you want the trigger to start. Plus, the sphere collision is the simplest for physics to compute. When there is a hit, the tile tells the parent to create tiles that aren’t already around it. Additionally, you can make it so that the first time it hits is the only time the master gets the message, so there are no redundant calls.

That way, you have one master in charge of everything, and all he does is wait.