Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 13 Next capture
2021 2022 2023
1 capture
13 Jun 22 - 13 Jun 22
sparklines
Close Help
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
avatar image
0
Question by $$anonymous$$ · Apr 12, 2014 at 05:40 AM · animatorrigidbody2dcollider2dontriggerenter2d

OnTriggerEnter2D fires multiple times when Animator component is on

Hi all,

I have an issue with OnTriggerEnter2D firing multiple times when a target's animator component is turned on. I've attached a project here to demonstrate the problem.

I created 2 entities, one called Car and one called Person, with the following settings: alt text

The scene starts out with the Car to the left of the Person. The Car moves toward the person using the Car's rigidbody2D's velocity. If the Person's Animator component is on, the OnTriggerEnter2D in the Car script will fire what looks to be every frame their colliders intersect. When I turn the Animator component off, it behaves expected and OnTriggerEnter2D only fires once. It doesn't matter if anything is even physically moving - I created an empty state for the Person's controller and set it as default and it still triggers multiple OnTriggerEnter2D's.

I set up this scenario with regular 3D colliders and it behaves as I expected, so I'm leaning toward this being a bug with the new 2D tools, but I'd like to be sure.

I've already tried searching for OnTriggerEnter2D issues on Answers and on Google, but most of them either involve triggers not working, or assumed to be firing multiple times because of a symptom arising from bad code.

Any help appreciated, thanks very much!

[2]: /storage/temp/25081-carsettings.png

trigger2dproblem.zip (183.7 kB)
entity_settings.jpg (85.5 kB)
Comment
Add comment
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

3 Replies

· Add your reply
  • Sort: 
avatar image
0
Best Answer

Answer by $$anonymous$$ · Apr 15, 2014 at 07:31 PM

I believe this indeed is a Unity bug. bansalgirish8's workaround only works in that specific use case, and even so, only once.

I've implemented a workaround where I maintain a list of colliders that have triggered OnTriggerEnter2D once before, and ignoring them for every subsequent trigger until they are removed by OnTriggerExit2D. Not sure it's the way to go, but it's the best workaround I've been able to come up with so far.

Comment
Add comment · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image
0

Answer by bansalgirish8 · Apr 12, 2014 at 07:43 AM

I faced the same problem.I have solved the problem in your scene attached below.

link text


25080-trigger2dproblem.zip (205.0 kB)
Comment
Add comment · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image
0

Answer by tabby_nat · Apr 21, 2014 at 07:32 AM

Seems like there are a lot of bugs with OnTriggerEnter2D. I have the same issue, where a transform.rotate causes OnTriggerEnter2D to fire on the same frame as the rotation, even though the trigger has not yet exited the collider. If your animation has a rotation of any sort, that would seem to reflect the same symptoms as my bug.

I'm pretty sure it's a bug.

Comment
Add comment · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

Your answer

Hint: You can notify a user about this post by typing @username

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this Question

Answers Answers and Comments

22 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

OnTriggerEnter2D - am I getting it wrong? 2 Answers

When you disable a gameobject, what happens to the rigidbody inside? 1 Answer

Keep Quad on Single Axis 0 Answers

set collision force after isKinematic disabled 0 Answers

[SOLVED] How to Destroy a rigidbody game object on collision with another gameobject? 4 Answers


Enterprise
Social Q&A

Social
Subscribe on YouTube social-youtube Follow on LinkedIn social-linkedin Follow on Twitter social-twitter Follow on Facebook social-facebook Follow on Instagram social-instagram

Footer

  • Purchase
    • Products
    • Subscription
    • Asset Store
    • Unity Gear
    • Resellers
  • Education
    • Students
    • Educators
    • Certification
    • Learn
    • Center of Excellence
  • Download
    • Unity
    • Beta Program
  • Unity Labs
    • Labs
    • Publications
  • Resources
    • Learn platform
    • Community
    • Documentation
    • Unity QA
    • FAQ
    • Services Status
    • Connect
  • About Unity
    • About Us
    • Blog
    • Events
    • Careers
    • Contact
    • Press
    • Partners
    • Affiliates
    • Security
Copyright © 2020 Unity Technologies
  • Legal
  • Privacy Policy
  • Cookies
  • Do Not Sell My Personal Information
  • Cookies Settings
"Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges