- Home /
Physics.CapsuleCastAll not detecting kinematic+trigger colliders
I'm working on a force-scrolling 2d game where a horde of bad guys are chasing the hero.
The bad guys have kinematic rigid bodies and trigger (capsule) colliders. I made the rigid bodies kinematic, since I'm just moving the bad guys around (not using forces) and set the colliders to trigger, because if they were not triggers, they would not collide with other kinematic rigid bodies (cars and other hazards).
Collision detection is working the way I want it to except that when I do Physics.CapsuleCastAll(...) it doesn't detect the bad guys' trigger colliders.
The reason I'm doing the Physics.CapsuleCastAll() is for bad-guy AI--so they can avoid running into each other as they pursue the hero.
Physics.CapsuleCastAll(...) does detect my bad guys if I make their colliders non-trigger, but then they no longer collide with other kinematic rigid bodies.
In summary, a couple of quesstions:
1) Is Physics.CapsuleCastAll() not supposed to detect kinematic rigid bodies with trigger colliders? (all the docs I have found suggest that they should)
2) Is there a better approach for what I'm trying to do, e.g. I could make the bad guys' rigid bodies non kinematic; it just seems like real physics would be a pain in this type of force-scroll 2d game.
Thank you in advance for any help.
I had some similar issues with capsule cast problems. I would put this in the "start up" bugs for the new features category. Proper question btw m8, and smart choice on nailing error scope by replacing capsule cast with raycast Definatly +1 , wish I had any form of decent answer though :)
Answer by Jessy · Jan 14, 2011 at 05:16 AM
Physics Manager, RayCasts Hit Triggers, turn it on.
Edit: Nope, should have checked, but I'll leave this here so that others know this isn't the solution. I'm calling this a bug.
Thanks for the quick reply.
I just looked at Physics$$anonymous$$anager, and Raycasts Hit Triggers is already checked, but somehow it's not seeing $$anonymous$$e.
I'm assu$$anonymous$$g all settings and rules for raycasting apply to capsulecast functions as well, but I might start experimenting with switching to raycast just to rule that out.
Any other ideas for what it might be?
I'm very sorry, this should not be a problem. I just filed this as bug 388559.
In the meantime, try this workaround found in the comment to my answer: http://answers.unity3d.com/questions/36453/what-is-the-proper-usage-of-spherecast/36456#36456
Thanks for all your help and for filing the bug. The linked workaround doesn't work for me, but knowing now that the problem is with SphereCast/CapsuleCast and that RayCast does not have this bug, I switched my code to use RayCastAll. With RayCastAll, at least the collisions are detected, even if they're not as accurate as I wanted them.
Thanks again for all your help on this.
FYI, below is the workaround I'm using. It's really only suitable for 2d case where false positives are not an issue, e.g. I'm using it for a very simple enemy path finding algorithm.
Your answer
Follow this Question
Related Questions
Can't click gameobject when over another trigger? 1 Answer
Play audio only once in trigger collision entry? 1 Answer
Access other collider without use of Trigger collider. 1 Answer
How to add a specific object from one array to another ? 1 Answer
How to handle multiple colliders for one enemy and bullet. 3 Answers