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 Zeek Aran · Dec 03, 2012 at 04:23 AM · triggerdestroy

TriggerOnExit not activating after Destroy

I have a mine with a large bounding sphere. When I enter the sphere, TriggerOnEnter works just fine. When I leave the sphere, Exit works fine. When I activate the mine and it explodes and I call Destroy, TriggerOnExit doesn't activate until I leave the area of the sphere that shouldn't exist. What am I missing?

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 whydoidoit · Dec 03, 2012 at 09:01 AM 0
Share

Does the $$anonymous$$e have a rigidbody attached? If not I suggest that you add one with is$$anonymous$$inematic set to true. The collider should then immediately be gone. In general you should not have colliders without rigidbodies for anything that might move or vanish.

2 Replies

· Add your reply
  • Sort: 
avatar image
0

Answer by MarkFinn · Dec 03, 2012 at 05:10 AM

This is the expected behavior I'm afraid. When a collider is removed it does not shrink to nothing, it just goes away. I'm surprised you get the Exit Trigger when you leave the area though. We didn't.

Long story short, when you destroy an element that has trigger interactions with other objects you need to code the correct reactions into the code that decides to destroy the object.

Imagine you are standing in a house which is suddenly completely vaporized by an invading aliens main cannon, leaving you standing on a patch of perfectly flat open ground. Did you exit the house? No. There just isn't a house any more. Same deal for vanishing colliders.

Comment
Add comment · Show 4 · 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 Zeek Aran · Dec 03, 2012 at 08:58 AM 0
Share

So what do you suggest?

avatar image MarkFinn · Dec 03, 2012 at 09:28 AM 0
Share

When you destroy an element that has trigger interactions with other objects you need to code the correct reactions into the code that decides to destroy the object.

avatar image Zeek Aran · Dec 03, 2012 at 04:57 PM 0
Share

I get that, but that's very vague. If I knew what those were I wouldn't be asking.

avatar image MarkFinn · Dec 04, 2012 at 04:51 AM 0
Share

Ah, I mean that you need to perform the same actions as are in your TriggerOnExit in the code that calls Destroy on the $$anonymous$$e (assu$$anonymous$$g that you want the same thing to occur).

Best done by moving the contents of TriggerOnExit to a new function/method and calling that from TriggerOnExit and from the code that calls Destroy.

avatar image
0

Answer by Zeek Aran · Dec 05, 2012 at 10:14 PM

I eventually got it working by calling a method of the player gameobject from the mine gameobject.

Mine script:

if (distance < 10) { GameObject ship = GameObject.FindGameObjectWithTag("Player"); ShipController controller = (ShipController)ship.GetComponent(typeof(ShipController)); controller.DestroyMine(); Destroy(this.gameObject); }

Player script:

public void DestroyMine() { OnTriggerExit (null); health -= 25; } void OnTriggerExit(Collider other) { underAttack = false; }

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

11 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

Related Questions

Why is this rigidbody not activating the trigger? 0 Answers

Putting an object somewhere to destroy something else 1 Answer

destroying instructions sequence 1 Answer

gui does not appear after trigger? 1 Answer

OnTriggerEnter not working 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