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 Kaldhu · Nov 18, 2013 at 05:20 AM · 2dontriggerenter

OnTriggerEnter2D not working on second Trigger events

I have a box collider 2D with tag "Collider" which has isTrigger = true and in my player object I have a rigidbody 2d and a box collider 2d.

the code below is within a script within my player object Now the onTriggerExit2d runs the first time just fine same as the enter but if i try to exit and enter the object again this code doesn't run and i don't know why this is.

 void OnTriggerExit2D(Collider2D hit)
 {
     print("Collider Exit");
     
     if(hit.gameObject.tag == "Collider")
     {
         print("Left Collider");
     }
 }
 void OnTriggerEnter2D(Collider2D hit)
 {
     print("Triggered Entered");
     if(hit.gameObject.tag == "Collider")
     {
         print("Entered Collider");
     }
 }

EDIT: Ok I was dumb it is working i just expected my console to write each line as it was told to and not stack matching prints ¬_¬ (I hadnt slept for 24 hours when i posted this)

Comment
Add comment · Show 1
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 sspross · Nov 18, 2013 at 12:46 PM 0
Share

Hm... does it work when you use CompareTag ins$$anonymous$$d?

 hit.gameObject.CompareTag("Collider")

Edit: I just tried it out and it works in both ways in may setup. $$anonymous$$aybe you change your collider object or something. can you post your hole palyer script?

1 Reply

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

Answer by Kaldhu · Nov 18, 2013 at 05:38 PM

This Has Been solved (well there never was an issue)

Comment
Add comment · Show 1 · 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 c1pr1an · Jul 22, 2014 at 05:18 AM 0
Share

Haha had the same problem for 4 hours!

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

19 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

Related Questions

Method doesn't work when called in other script 0 Answers

OnTriggerEnter 1 Answer

How can i detect hits from enemies inside of a player? 1 Answer

How to make kinematic platform trigger events 0 Answers

OnTriggerEnter2D with multiple objects 0 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