Do Triggers Need Rigidbodies? (Beginner Question)

Hey guys, just a pretty simple question, do all triggers need to have a rigidbody? Say you have non-moving invisible trigger that when the player steps on it, opens a door. Would I need to give this object a rigidbody/kinematic rigidbody?

1 Like

No, this object doesn’t need a rigidbody. Only the player should have a rigidbody.

2 Likes

Okay, could you explain this for me also, from the unity manual: Even when immobile, kinematic rigidbody colliders have different behavior to static colliders. For example, if the collider is set to as a trigger then you also need to add a rigidbody to it in order to receive trigger events in your script. If you don’t want the trigger to fall under gravity or otherwise be affected by physics then you can set the IsKinematic property on its rigidbody.

Okay, could you explain this for me also, from the unity manual: Even when immobile, kinematic rigidbody colliders have different behavior to static colliders. For example, if the collider is set to as a trigger then you also need to add a rigidbody to it in order to receive trigger events in your script. If you don’t want the trigger to fall under gravity or otherwise be affected by physics then you can set the IsKinematic property on its rigidbody.

Just make it easier for me to understand what this is saying.

Several parts of the manual regarding colliders and rigidbodies are outdated and come from the Unity 5 era. As for today, static colliders raise trigger events when any other rigidbody (either kinematic or not) contacts them.

For example, I use static colliders (without rigidodies) in racing tracks for detecting shortcuts. Each collider is marked as Trigger and includes a script that listens to the OnTriggerEnter event. Works flawlessly:

2 Likes

So just to clarify, you put the OnTriggerEvent script inside the actual trigger itself, and if it detects an object with a tag of “racecar” then it will react to it and do something?

And I am just caught up on that sentence above (“even when immobile, kinematic colliders are different to static…”) that I don’t understand. Are you telling me that sentence is outdated or something. If it’s not could you explain it to me word for word cause the wording in the sentence is just confusing.

Yes, I’ve put a script in the same GameObject as the trigger itself. The script contains a method “OnTriggerEnter”. This method is called whenever any Rigidbody touches the trigger. The method receives the information of the colliding object, so you can take your decisions based on the tag or any other property.

Are you seeing the correct documentation? I can’t find anything like that in the Unity docs. Maybe you’re reading the docs for a (very) past version of Unity:

https://docs.unity3d.com/ScriptReference/Collider.OnTriggerEnter.html

1 Like

The docs are accurate afaik: One of the entities is required to have a Rigidbody. It’s simply a matter of where you put it. Do you want it on the trigger? the other? both? Does anyone care? You decide.

If you have a niche case regarding kinematics/statics then you should clarify the conditions and give an example of something that is not working.

This sentence is confusing though cause it sounds like it’s saying that all triggers need to have a rigid body. The wording in the sentence is kind of confusing and I don’t know what it’s trying to say, I’m just a beginner. I just want to know what this means in really simple terms.

1 Like

Yes, it is in the kinematic rigidbody collider section in the second paragraph: https://docs.unity3d.com/Manual/CollidersOverview.html

Oh, ok. That information requires an update. It doesn’t mention that you can make kinematic colliders interact seamlessly with other colliders with the Contact Pairs Mode option in the Physics settings:

I always configure “Enable All Contact Pairs” in my projects so kinematic bodies work the same way as non-kinematic ones.

1 Like

What is confusing? It seems fairly straightforward to me - simply one of the Colliders involved has to have a Rigidbody also.

If you have an overlapping pair of colliders then at least one of them must have a Rigidbody to activate the collision and trigger events as needed for everyone involved. Consider a bunch of buildings in a city. They don’t need rigidbodies because the active rigidbodies moving around during gameplay are going to be the ones ‘triggering’ events when they are needed. Are you not seeing this be true in your tests?

It feels to me like this is saying that if you have a collider that’s a trigger, then you also need to add a rigidbody to it, but that’s not always true. I don’t really understand the example it’s giving and I also don’t understand how immobile kinematic rigidbodies are different than static colliders. Could you explain it super simple and easy of a word for word of the sentence I don’t understand. Sorry I don’t get it, I’m still learning.
Is it just saying that if you have a trigger then somewhere in the equation there needs to be a rigid body?

Forget that information. It’s incomplete (see my post above).

Super-simple:

  • Open Project Settings > Physics. Configure “Contact Pairs Mode” to “Enable All Contact Pairs”.
  • Add Rigidbodies to the physically moving objects only.
  • Use static triggers, static colliders, OnTriggerEnter, etc normally. Any project, any platform (desktop, mobile, etc)
2 Likes

How exactly are immobile kinematic rigidbody colliders different than static colliders?

Edy is more familiar with the technicals, but I can explain what I know

Static colliders are supposed to be things that never move. You flag them as static and expect it to never change. This lets some calculations process them faster because it knows they shouldn’t ever be moving. An example would be a bunch of buildings, or props, or terrain.

Kinematic is just a Rigidbody that does not receive forces. An example would be a character that you control explicitly and don’t want other forces interfering. Drop a kinematic box into a pile of non-kinematic boxes and it will plow them completely out of the way no matter what their mass is. If it’s ‘immobile’, I assume you mean it’s just not moving. In that case, it’s just a Rigidbody that isn’t moving and isn’t going to be moved by random forces hitting it. Pretty simple.

So the sentence above that I was so confused on is wrong. Because not all triggers need rigidbodies to receive trigger events, yet it still says "For example, if the collider is set to as a trigger then you also need to add a rigidbody to it in order to receive trigger events in your script". Sorry if I’m wrong but that’s what I’ve been so confused about.

1 Like

It’s not really the colliding I’m worried about but I get what you’re saying. Tell me though, if this option was not enabled and not possible to change, what is this sentence trying to say?