- Home /
OnTriggerEnter without RigidBody
I am trying to move an object through a trigger, and I can absolutely not use a rigidBody. According to http://docs.unity3d.com/Documentation/ScriptReference/MonoBehaviour.OnTriggerEnter.html I dont necessarily need a rigidbody it says "rigidbody (or the collider if there is no rigidbody)" but it's not working for me. Does it not work for a Sphere Collider, does that not count?
Answer by aldonaletto · Sep 12, 2012 at 01:24 AM
Add a rigidbody to the trigger and check its Is Kinematic checkbox: kinematic rigidbodies don't react to collisions nor suffer gravity effects, but enable the trigger to detect any collider.
I can't use rigidbodys the ball freaks out. I've been having problems with rigidbodys because one of my objects is a tube I made in maya and it doesn't work well for some reason.
That's why you must make it kinematic: a kinematic rigidbody isn't affected by forces, gravity, collisions etc., but makes the trigger detect simple colliders. Try it.
erp, well thats embarrassing, I thought I had tried that already. Well, thank you.
Why is this necessary to add the rigid body? Anyone from Unity care to chime in?
Without the rigidbody component collision checks would be happening on every single collider at any given time in a scene. The rigidbody allows collision checks to be limited to only the object that has the component.
For example, if you're only ever checking against collisions (or triggers checks) from the player to objects in the scene, you only ever need to have one rigidbody that does the check at, the player.
In my case I found I had to add a rigid body to both my capsule collider (the player) and the other collider. The other collider is a small collider that starts off contained entirely in the player capsule collider, but I still want trigger entered call. Without the second rigid body in the smaller collider, on trigger enter was not called. Is it the receiving collider (the one with the script that has on trigger enter) that must always have the rigid body?
Answer by luiscmendez · Sep 12, 2012 at 12:48 AM
The shape of the collider doesn't matter. What exactly is your issue? Will the object not pass through? If so, then you probably need to check on the "Is Trigger" box on the object that is the trigger in the inspector.
No the object passes through, and the box is checked, but the function wont trigger.
Answer by mkgame · Sep 26, 2018 at 06:58 PM
Hi, I have similar issue. Kinematic Rigidbodies are slow in Unity 2017/2018. The bug entry is this one: https://issuetracker.unity3d.com/is...ger-time-on-2017-dot-2-0a4-and-later-versions. Rigidbody with kinematic on setting was very fast in Unity 5, but this has changed in 2017 version. I guess if you get OnTriggerEnter, then you can attach the Rigidbody to the GameObject (to simulate the physic if necessary), if needed. Not sure what the best solution is right now. You can wait for the fix and ignore the performance issue, or change back to Unity 5.6.6f2.