• 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
2
Question by yardlevy · Jun 20, 2013 at 08:44 PM · collisiontriggerontriggerexit

OnTriggerExit is getting called even tho neither object moves

Hello All, I have an Static Trigger Collider that is a child of my camera which has a kinematic rigidbody. I use this trigger collider to activate gameplay objects when they enter it and deactivate them when they leave it. The gameplay objects that are being activated and deactivated have Static Non Trigger Colliders. Now this works most of the time, in that my gameplay objects are activated when they enter the activation collider and deactivate when they leave it. The problem is that sometimes when the gameplay objects are inside the activation collider and neither the gameplay object or activation collider is moving or changing in any perceivable way, I will get an OnTriggerExit() event on the gameplay object indicating that it had left the activation collider even tho the transform of neither object changed.

Why would this happen? What can I do to prevent this from happening.

Thanks,

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 vinipc · Jun 21, 2013 at 02:21 PM 0
Share

I'm having the same problem. I'll add in some details, see if it helps.

Here's the code I'm using:

 function OnTriggerExit(other: Collider){
     if (other.tag == "mesa"){
         print("OnTriggerExit");
         manager.dragging = null;
         manager.ponta = null;
         }
 } 


(never$$anonymous$$d the portuguese).

The object with this script has RigidBody and it's Collider is a trigger. When it touches the other collider, it'll trigger an OnTriggerEnter function and then, after a few moments of staying still, will trigger the OnTrigger Exit. If I move the object (with the colliders still colliding), it'll trigger OnTriggerEnter again, and then OnTriggerExit after a moment.

avatar image Louis-N-D · Aug 25, 2014 at 10:33 AM 0
Share

No answer from me, unfortunately! I have almost the opposite problem. I put culling volumes throughout my level. These are simply box colliders set as triggers. Entering one enables it's chuck of the level, while exiting will disable the associated level chunk. $$anonymous$$y player uses a character controller but the culling volumes themselves have the script on them to detect the onTriggerEnter and Exit. Well, about 50% of the time, if I stand somewhere and let an enemy hit me (can't be moving the player for this to work) an onTriggerExit will get picked up by whatever culling volume I'm in and the level chunk will disappear for one frame as a onTriggerEnter is called right after.

avatar image Mayank Ghanshala · Aug 25, 2014 at 11:28 AM 0
Share

check all the axis. $$anonymous$$ay be one of them is not same ...

avatar image SterlingStudios · Aug 25, 2014 at 11:42 AM 0
Share

You don't need the 'other.tag == "mesa"'. Basically you are calling the object tagged as 'mesa' without being inside the trigger, even if you are half way across the map from it.

1 Reply

· Add your reply
  • Sort: 
avatar image
2

Answer by jasonpvp · Dec 28, 2015 at 04:53 PM

@yardlevy I'm new to Unity (using v5) so don't quote me on this, but I experienced the same thing when I had two colliders on the same object - one that was for physics collisions and the other just a trigger. When I moved the physics collider to a child object the problem vanished. I think this tutorial mentioned something about it: https://unity3d.com/learn/tutorials/projects/stealth/single-doors?playlist=17168

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

20 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

Related Questions

2D game object trigger 1 Answer

Weird OnTriggerEnter / Exit behavior 1 Answer

Why is OnTriggerEnter2D executing multiple times before I get an OnTriggerExit2D? 1 Answer

Can someone clarifies OnTriggerEnter, OnTriggerExit and OnTriggerStay for me? (I have image included already) 0 Answers

OnTriggerEnter Being Called On Unexpected Object 1 Answer


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