hey Folks, i know this has been asked previously but none of them helped me to sort out… i have animals in my game on them i had rigidbody character controller and box collider too. but when they chase player they gets overlapp each other. i want them to stay way from each other. help thanks in advance…
Then don’t make it a trigger as rigidbodies can pass through trigger. Uncheck the Is Trigger checkbox and you’re good to go.
The way i did it in mine is really crude, but for my case it helped. I assigned each animal an integer, and that integer showed its order in importance if you like. Then i made a function for OnTriggerEnter, to check that integer on the collider that entered that trigger. If the incoming trigger is of higher value than its own, then it has to give way. Basically reduce its movement speed or turn around. It doesn’t work for a lot of animals together, but for a couple it helps.
Perhaps you’ll get some ideas out of this, like changing it to work with raycasting so that the enemy will know from advance that it needs to go around.