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
1
Question by grangerave · Dec 25, 2012 at 09:50 PM · triggercharactercontrollerontriggerexit

[fixed] OnTriggerExit never called if I change Character Controller center in-script...

Hello-

I have a setup in 2d where I need to know when my player (which has a character controller, and attached movement script) ENTERS and EXITS an invisible trigger box. I put a script on the box with an OnTriggerEnter() and OnTriggerExit(), and it works fine, until I started changing the Character Controller center inside the movement script: now, OnTriggerEnter() is getting called every few frames, while OnTriggerExit() is never called....... I'm constantly changing the center based on if the player is crouching or not. The specific section of the code giving trouble looks like this:

 void Update(){
      if(crouching){
           controller.center = new Vector3 (0, 0, 1.78f);     //this is the problem
           controller.height = 4.36f;
      } else{
           controller.center = Vector3.zero;     //this is the problem
           controller.height = 6.92f;
      }
      //...
      //movement and other things
 
 }

I could try to find a workaround, but if someone could give some insight into fixing this problem, I would greatly appreciate it!

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

2 Replies

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

Answer by grangerave · Dec 25, 2012 at 10:01 PM

I updated it to only change the charactercontroller center once using an if statment, all problems went away!

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 ofusion · Nov 18, 2015 at 11:16 AM

I meet the same problem. I verify that change CharacterController's center is indeed the reason that trigger's OnTriggerExit is not called.
It is probably a Unity bug. I am using Unity 4.6.6p4, the bug still exists!

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

10 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

Related Questions

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

mesh collider inside character controller 0 Answers

OnTriggerExit not triggered when object/trigger inside is destroyed c# 1 Answer

Make object react to certain triggers only 1 Answer

Box collider with strange behaviour 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