- Home /
Box collider triggers interfering with rigidbody movement
Ladies. Gentlemen.
A good bit ago, an interesting issue had suddenly arisen. There was something interfering with the movement of my character (Who has a rigidbody). I really had no idea what was going on, but I finally discovered the cause the other day. For some reason, the colliders that I'm using as attack hitboxes are the source of the issue. Of course, they're set as triggers.
It's the most annoying thing; rigidbody.velocity only actually works in one direction (Can't go up or right. Only left), the character sometimes gets stuck in one of the colliders, etcetera. Even if I'm nowhere near any other colliders, the issue persists. I had tried messing with the physics settings as well, but if they ignore collisions, then they're useless as triggers.
So what's going on here? If a collider is set to trigger, shouldn't it be unable to mess with objects?
Answer by Chris D · Jul 24, 2011 at 01:26 AM
Yes, colliders with isTrigger = true will not interact with physics objects (physically...).
Check the rest of your setup and code, it has to be somewhere else.
But wouldn't the fact that the issue goes away after getting rid of said colliders mean that they're the cause?
Answer by aldonaletto · Jul 24, 2011 at 03:16 PM
If you're using the Character Controller, you're a victim of the "added colliders bug": if you child to the Character Controller some object with a collider, the controller movement becomes very weird: some directions are blocked, or it strafes when trying to go in some directions, or moves to the wrong direction - all depending on how the childed collider intersects the capsule. If this is the case, avoid the added colliders to touch the Character Controller capsule. Setting Is Trigger in such colliders also solves the problem, if it can fit your game logic.
Those are definitely the issues I'm getting, aside from using a Rigidbodyrather than a Character Controller. But in order to get good results with movement and such, I'm using a box collider to give the character a consistent hitbox. None of the triggers are hitting it, but could that be doing anything?
It seems that the main collider "thinks" it's colliding with its children. In the Character Controller, the problem ceases when the childed collider is at a certain $$anonymous$$imum distance from the character - but also if it's set as a trigger (opposite to your case). I have some illogical suggestions to you:
- Try to move the triggers away from the main collider and check if they still disturb the movement;
- Add kinematic rigidbodies to your triggers;
- Change the triggers shape;
These suggestions don't make too much sense at all, but that's the way bugs are: complete nonsense. $$anonymous$$aybe some illogical thing like this may prevent the bug.
From what I can tell, the issue is actually stem$$anonymous$$g from my triggers intersecting the Skinned $$anonymous$$esh, despite the fact that it has no collisions, is on a layer set to be ignored by everything, and has its bounds set to zero. Gaaah!
Answer by testure · Jul 31, 2011 at 03:35 PM
FYI- I ran into this problem as well:
http://answers.unity3d.com/questions/131688/triggers-with-rigidbodies-are-pushing-each-other.html
Never figured out what was doing it, but one day it just stopped. I'd been working in a totally unrelated part of the game, so there's no way I 'accidentally' fixed it. My guess is that it's a rogue bug in Unity.. I haven't figure out a way to reproduce it in a sterile environment. I would recommend sending your project files to Unity to examine (if you're able to). From my experience it is extremely frustrating, and the fact that it just came out of the blue and disappeared the same way is very concerning.
Yeah, it came out of nowhere for me as well, the confounding thing.
Your answer
Follow this Question
Related Questions
Physics Possibilities?: Angles, Penetration, Exceptions 4 Answers
Unity 2D Trigger Detection is not working. 6 Answers
OnTriggerEnter mesh collider problem 1 Answer
Rigidbody Trigger 1 Answer