Detect Foot Collision?

jasontuttle

New member
Hi Justin,

I'm trying to find a way to detect when my player jumps on top of an enemy and the player's foot collides with an enemy's head. Both my player and enemy are UCC characters. The enemy is AI controlled using Behavior Designer.

The problem I'm running into is that collision between player and enemy is currently controlled by the default UCC capsule colliders. I've tried adding child objects with trigger colliders to the enemy's head and players feet, but the default UCC capsule colliders get in the way of detecting the head/foot collisions. As a result, the collisions don't look right. Collision gets detected when the player is floating above the enemy, before his foot touches the enemy's head.

Is there a way around this problem?

Thanks in advance for your help!
 
I was first going to suggest a trigger route but it doesn't sound like that works too well. One other method may be to fire a small raycast down from each of the player's feet. If that raycast hits an enemy then you know that the character is on top of the enemy. This will also allow you to adjust the magnitude of the raycast.
 
I was first going to suggest a trigger route but it doesn't sound like that works too well. One other method may be to fire a small raycast down from each of the player's feet. If that raycast hits an enemy then you know that the character is on top of the enemy. This will also allow you to adjust the magnitude of the raycast.

Thanks Justin. -- It took some doing, but I got it working. Just in case anyone else ever needs to do something similar, here's what worked for me:
  1. I used the CharacterLayerManager to make it so that my Enemies and Player do not collide with each other at all.
  2. Created two new layers: PlayerCollision and EmemyCollision. I set these new layers to only collide with each other.
  3. Added child objects to all of the important bones on my Player and my Enemies
  4. Put these child objects on the PlayerCollision and EnemyCollision layers respectively.
  5. Added colliders and triggers to those child objects.
  6. Added a script to each of the child objects on the Enemies that responds to collision with the Player's child objects.
As always, thanks again for all your help.
 
Last edited:
Ya i tried using triggers for feet doesn't work. Idk how the new foot steps system works in UCC? Doesn't seem to use colliders. It must be using ray casts.

Nice to hear you got a work around. I would strongly suggest not to modify UCC physics setup though. Could run into issues with stuff not working in the future. Updates,add ons or a system thats part of UCC you just haven't tested yet in your game.

I would suggest doing the ray cast idea. Really shouldn't edit UCC unless you absolutely have too.
 
I would strongly suggest not to modify UCC physics setup though. Could run into issues with stuff not working in the future. Updates,add ons or a system thats part of UCC you just haven't tested yet in your game.

I would suggest doing the ray cast idea. Really shouldn't edit UCC unless you absolutely have too.

Good advice, but please note: I didn't edit UCC.
  1. I configured the CharacterLayerManager per the documentation.
  2. I also created 2 layers and configured their collisions using the Unity Physics Manager.
  3. Last but not least, I added some child objects to my character/enemy skeletons. Doing so shouldn't necessarily break UCC. Adding child objects is part of the documented UCC workflow. You add them when you create weapons for your characters to hold/fire.
Of course, it's certainly possible that I did something that might break UCC, but so far in my testing, my solution seems to work quite well while following what I think are UCC compatible practices.

Thanks for your advice and words of caution. I know they were well intentioned, and I very much appreciate it. I just thought I should clarify for future reference. I often find solutions to problems I'm having on this forum, and I wanted to document this solution in case anyone else might benefit from it.

: )
 
Top