OnCollisionEnter called multiple times?

I’m having trouble with a car that goes through a collider that is marked as trigger. Now I check in the car script the “OnCollisionEnter” event and check whether I go through the trigger collider. What happens now is that onCollisionEnter is triggered multiple times.

I would have expected to get that one called only 1 time, as the car comes into the volume of the trigger collider. I can’t get my head around what I did wrong. Isn’t a collisionEnter call to be supposed to be called only once, exactly one time when the entering happens and not multiple times?

Any help greatly appreciated! :slight_smile:

Martin

perhaps the car penetrates the volume too much and is “kicked out” by force which would allow it to enter again

Hello Martin,

I saw this once before. I scratched my head over it until I finally noticed I had inadvertently attached two copies of the script to the game object.

In addition, it’s probably a typo but you don’t use OnCollisionEnter for triggers.

Ooooh yes, that might be the reason, thanks will test that tonight and see if it works! Thanks! Will be back here with the results.

Oooohh stupid me btw, of course there have been multiple objects going into the trigger… the left wheel, the right wheel, the body… ahhhh that is so emabarissing to me that I didn’t think of that… I saw it only as “one” car, not as multiple objects during test… haha, but anyway, now it works! :slight_smile:

2 Likes

Hey Martin!
Your post is still helpful after 12 years. Many thanks for your feedback. I ran excatly into the same issue. I also attached multiple objects detecting multiple collisions altough there is presumably only “one” object. I fixed it now and it works! =)

1 Like

Thankyou so much. for any other users out there with the same problem to this day, basically the OnTriggerEnter() function is called for every collider entering the trigger which is a child to the parent object containing the script with the OnTriggerEnter() method in it. Hopefully this is helpful.

:roll_eyes::p:p:p:p:p:p:p:sweat_smile::roll_eyes::roll_eyes::roll_eyes::roll_eyes::roll_eyes::roll_eyes::roll_eyes::roll_eyes::roll_eyes::roll_eyes::roll_eyes::roll_eyes::roll_eyes::roll_eyes::roll_eyes::roll_eyes::roll_eyes::roll_eyes::roll_eyes::roll_eyes::roll_eyes::roll_eyes::roll_eyes::p:p:p:roll_eyes: