• 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 NoWayMan112 · Aug 19, 2014 at 08:05 AM · ontriggerenterontriggerexit

OnTriggerEnter works once, OnTriggerExit not at all?

Hi I have the player controlling a cube with a box collider and rigdidbody. When the player mesh collides with the sheep mesh I get the message "Collision Detected" but when I leave the area of the sheep mesh I do not get the message "Left Collison".

     void OnTriggerEnter(Collider other)
     {
         if(other.gameObject.tag == "sheep")
         Debug.Log ("Collision Detected");
     }
     void onTriggerExit(Collider other)
     {
         if(other.gameObject.tag == "sheep")
             Debug.Log ("Left Collison");
     }

The sheep objects have sphere colliders and sheep tags. Why is it not detecting when I have left the area of the sheep objects?

Comment
Add comment · Show 4
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 bob1234 · Aug 19, 2014 at 08:11 AM 1
Share

remember to have a capital O as in OnTriggerExit

avatar image jgresham bob1234 · Feb 19, 2017 at 03:32 AM 0
Share

THAN$$anonymous$$ YOU!!!

avatar image HarshadK · Aug 19, 2014 at 08:21 AM 0
Share

It is one of the major reasons why triggers or collisions don't work for many people.

avatar image tanoshimi · Aug 19, 2014 at 08:23 AM 0
Share

The others being lack of rigidbody, setting "IsTrigger" (or not), using the wrong function signature, not checking the correct tag of the colliding object.... basically, not reading the documentation ;)

1 Reply

· Add your reply
  • Sort: 
avatar image
0

Answer by DBar · Aug 19, 2014 at 08:27 AM

Indeed tanoshimi. Collisions works. We have overflow malfunction somedays. Ouch.

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.

Welcome to Unity Answers

If you’re new to Unity Answers, please check our User Guide to help you navigate through our website and refer to our FAQ for more information.

Before posting, make sure to check out our Knowledge Base for commonly asked Unity questions.

Check our Moderator Guidelines if you’re a new moderator and want to work together in an effort to improve Unity Answers and support our users.

Follow this Question

Answers Answers and Comments

6 People are following this question.

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

Related Questions

walk through an object once 0 Answers

Can someone please tell me why this code isn't working? 1 Answer

OnTriggerEnter function in c# 0 Answers

Make object react to certain triggers only 1 Answer

OnTriggerEnter/Exit called unexpectedly 2 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