• 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 JeffBert · May 27, 2015 at 10:31 PM · ontriggerenterontriggerexit

Object interaction inside of a trigger that only uses OnTriggerExit method

I'm trying to decide between two options for a "kill zone" when objects get passed a certain point. The two options I've come up with is either using 4 triggers with OnTriggerEnter or just one with OnTriggerExit.

alt text

The OnTriggerExit initially looked more interesting since it only has one collider but I'm unsure if objects will constantly make empty calls and "trigger" (sending messages to the trigger that won't be received) with it even if the script doesn't have OnTriggerEnter or OnTriggerStay methods.

triggers.png (4.0 kB)
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
1

Answer by redeemer · May 28, 2015 at 12:32 AM

Hi,

For what I know, if you don't use OnTriggerEnter/OnTriggerStay/OnTriggerExit mathods, they won't be called. In terms of performance it would be better to have just one trigger instead of four. None the less, you can test it on the profiler, but I don't think you will see any advantages unless you have multiple kill zones in your scene and each one of them have four triggers. I mean, if you only have one kill zone there won't be much of a change but if you have 100 kill zones it would mean you'll have 400 triggers...hope I made my point and it helps.

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
1

Answer by crohr · May 28, 2015 at 12:25 AM

My best optimization tip for you would be to make your collider on its own layer (perhaps KillZone) and then edit the physics Layer Collision Matrix for the KillZone layer. For instance, if only the layer (Player) is concerned with the kill zone then just mark Player in the Matrix.

As for using 4 colliders versus 1. I would stick with 1. Collision detection is more computationally intensive than send the trigger messages. Although, if you don't have many GameObjects on the screen at once, there is not much of a difference.

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

21 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

Related Questions

Strange OnTriggerEnter/Exit() Behavior 0 Answers

On trigger exit not working 2 Answers

Changing the rotation of a Trigger makes the Trigger not work anymore? 1 Answer

How to make multiple gameobjects instantiate from one collider? 3 Answers

issues with on trigger enter and exit 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