Maybe there’s something that I don’t understand, but I was under the impression that triggers can only trigger each other when both objects have a kinematic rigidbody attached. However, I have 1 object with no rigidbody and a trigger collider and 1 object with a rigidbody (dynamic) and a trigger collider and both trigger colliders are triggered when they intersect. How do i prevent this from happening?
I only want these triggers to fire when they are intersected with non trigger colliders.
I’m not sure, but if you check out the bottom of this page it does look like they respond to each other.
Note any collider that moves should have a (kinematic) rigid-body. This tells the engine the collider might move and it’s handled appropriately in some sort of collision engine that probably does like, binary space partitioning or something to decide who might collide (and thus who needs to be tested). It’s usually your typical “divide them in half until you have small enough groups” type deal.
Static colliders (any collider without a rigidbody) are telling the engine “this one isn’t going to move” and they’re handled in a different way that has to be re-done if you do move them, which will blow your game right on up.
What’s your use case in general terms? It sounds to me like you need layers and layer masks.
The object without the rigidbody only rotates and doesn’t use physics to do it.
My use case:
The turret (only rotates) uses a trigger collider to find the player within its range. It also has a second non trigger collider to take damage.
The player (uses rigid body and physics to move) uses a trigger collider to find specific objects that can be interacted with. It also has a second non trigger collider to take damage.
When the player gets near the turret (not in it’s range) the turret detects the players trigger collider and adds it to the target list anyway. Then it adds it a second time when the players collision collider also enters the turrets range.
So the turret is adding the player twice to the target list, one for each collider (which i can fix easily), but the bigger problem is that the turret is detecting the player further out than it should because it’s triggering as soon as it sees the players trigger instead of only triggering when it sees the player.
How would i go about fixing this? Since both the turret and the player need to detect things in their ranges.
Also, thanks for that link. I did search the API for answers to this, but not the manual -_-
Rotation is movement as far as a collision volume is concerned- it has to do math to decide if there are overlaps and that changes if it’s rotating. It needs a rigidbody, though that’s neither here nor there.
I thought you could layer mask trigger colliders like you can raycasts but I guess not. I think you’ll need to put logic in the OnCollisionEnter(s) that decides what to respond to.
So let me get this straight, this is a 2D collider, so even though the object is rotating on only 1 axis and the collider is 2D the object still needs a rigidbody? From my perspective since the object never moves from its position the collider is also in the same position and i don’t think it would be necessary. If you can confirm that it surely needs one i’ll add it.