Detecting Collisions with UCC

KO_Games

Member
I am having a hard time getting my character to detect a collision (using third person character controller). I know I'm missing something super obvious (and it might not be related to the UCC), but I can't figure out what the problem is. I started a new scene. Set up a character. Create a cube in the scene. Add a simple script on the cube with an onCollisionEnter script that just prints to the logs. I then walk my character into the cube and it collides with the cube because the character is not moving through the cube...but the script doesn't get called and no log gets printed to the console. What am I missing? I tried checking the collider layer mask and the character layer manager, but I can't get it to work.
 
OnCollisionEnter won't be called because technically the character never collides with another object. In order to detect objects you'll need to manually perform the cast yourself.
 
Taking a step back what is your goal? It may be easier to have the character detect the cube rather than the cube detect the character.
 
In my game, I have two characters in the scene. One is the player the other is the AI. I'm using the character controller on both. I'm using behavior tree as well for the AI. The level is supposed to end when the AI player touches the player. I was trying to use the bool to check for a collision for when the AI touched the player, but I couldn't get it to work. I tried using a workaround to check if the player was within a certain distance of the AI, but sometimes the game would end even when the player wasn't touching the AI because the AI was technically close enough. I realize I could lower the distance, but I wanted to see if there was a better way to handle this.
 
The trigger callbacks are still fired so you could add a slightly bigger trigger collider to your AI and then have the OnTriggerEnter callback fire when the game should end.
 
This makes sense now, spent the last few hours trying every thing I could think of. So there is no way to do OnCollision and no built in OnCollision in the controller? We have to use Trigger Colliders?

I love this controller for the locomotion but the way it breaks all physics things in Unity is a bit frustrating. Guessing there is no way around it to make the locomotion so good though.
 
Top