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 PvTGreg · Jun 12, 2015 at 09:25 PM · trigger

unity 5 on trigger exit bug

Ive tried every possible combination of colliders and ridigidbodys but this just does not work it will sometimes just keep the bool true why does it do this and what can i do to work around it

 void OnTriggerEnter(Collider collisionInfo) {
         if (collisionInfo.gameObject.tag == "Water") {
             inWater = true;
         } 
     }
     void OnTriggerExit(Collider collisionInfo) {
         if (collisionInfo.gameObject.tag == "Water") {
             inWater = false;
         }
     }
Comment
Add comment · Show 14
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 Wideopen411 · Jun 12, 2015 at 10:58 PM 0
Share

Sorry if you already tried this, but did you set something like

  void OnTriggerEnter(Collider collisionInfo) {
          if (collisionInfo.gameObject.tag == "Water") {
              inWater = true;
              Debug.Log ("Entered Water");
          } 
      }
      void OnTriggerExit(Collider collisionInfo) {
          if (collisionInfo.gameObject.tag == "Water") {
              inWater = false;
              Debug.Log ("Exited Water");
          }
      }


These debugs will pop up in your console telling you if your trigger is even working.

I would also try this. I also had tons of problems with triggers, but This is what has been working for me. remove the gameObject and just search for the tag

 void OnTriggerExit(Collider other)
     {
         if (other.tag == "Water") 
         {
             inWater = false;
             Debug.Log ("Exit trigger");
         }
     }


Also make sure that what your trying to collide with is tagged "Water".

avatar image PvTGreg · Jun 13, 2015 at 09:20 AM 0
Share

wouldn't have posted if i hadn't tried everything

avatar image PvTGreg · Jun 13, 2015 at 10:00 AM 0
Share

https://www.youtube.com/watch?v=e$$anonymous$$pGFtubrP8 heres a video showing it. as you can see it only works sometimes

avatar image zach-r-d · Jun 13, 2015 at 10:36 AM 0
Share

Is your character movement script using CharacterController.$$anonymous$$ove, or is it using Transform to move the player?

avatar image tanoshimi · Jun 13, 2015 at 09:27 PM 1
Share

If you believe you've found a bug, you should create a $$anonymous$$imal project that reproduces the problem and submit it via Help -> Report a Bug.

Show more comments

1 Reply

· Add your reply
  • Sort: 
avatar image
0

Answer by LinkoVitch · Jun 13, 2015 at 11:43 AM

Possibly a horrible hack, put perhaps use a combination of OnTriggerStay and LateUpdate?

In the OnTriggerStay test for water and set inWater to true as you are doing. Then in a LateUpdate reset it back to false. As I say, not the most eligant sollution but hopefully something that might work around your current issue.

I wonder if the issue you are seeing is due to the collider moving out of the water and back in within the same update and confusing the collision system? Is your player movement being done within Update or FixedUpdate?

Comment
Add comment · Show 7 · 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 PvTGreg · Jun 13, 2015 at 06:49 PM 0
Share

the movement is done in fixed update Could this be the problem?

avatar image PvTGreg · Jun 13, 2015 at 06:51 PM 0
Share

hmm no having it in Update makes it worse and not call triggerexit at all

avatar image PvTGreg · Jun 13, 2015 at 06:54 PM 0
Share

the lateupdate hack works. is there any problems i may run into using it?

avatar image LinkoVitch · Jun 13, 2015 at 07:08 PM 0
Share

I was thinking if you were already doing it in Update that moving it to FixedUpdate may work. Unfortunate that it wasn't the case, but I think it proves the issue is to do with the ti$$anonymous$$g of the collision.

I have no idea if long term the hack will cause further problems, sorry.

Just wondering, is the collider for the water mapped to the rippling surface of the water? If it is, perhaps make the collider a simple box collider just below the animated surface, I am guessing that as you leave the water and OnTriggerExit occurs, that perhaps the surface of the water is then moving and cancelling the exit. Does sound like unintended behaviour to me.

HTH

avatar image PvTGreg · Jun 13, 2015 at 07:18 PM 0
Share

na its a simple box collider set to trigger so really not sure why it does this

Show more comments

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

24 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 avatar image avatar image

Related Questions

Can't click gameobject when over another trigger? 1 Answer

Multiple animation with One Trigger ?!! 1 Answer

How do you make a trig object? 0 Answers

how to get collision to control servo motors 1 Answer

Unity Trigger 2D not working 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