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 Android Matt · Feb 24, 2013 at 06:17 AM · collideroptimizationontriggerenterkinematic

Check trigger/collider once?

Hi,

I have two closely related questions, the first which led to the second:

  1. How computationally expensive is it using many triggers and colliders (kinematic only)? I would assume that for OnTriggerEnter to be aware of a collision that behind the scenes it must be checked every frame?

  2. This led me to wonder, is there a way to check (only once, at a precise time) if there are any current collisions for a particular object with a trigger collider? Due to the structure of my game I know exactly when the OnTriggerEnter would be activated, but it is still very useful to use in order to access the objects involved in the collisions.

In a sense, it would be useful to turn on the 'OnTriggerEnter' for a short period of time, and the turn it off again afterwards since I know that I will have no relevant collisions. If it would be a form of optimization then I would like to try it.

Thanks,

Matt

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

1 Reply

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

Answer by nsxdavid · Feb 25, 2013 at 07:17 AM

You can achieve this in a sense by setting the trigger collider's enable to false when you are not wanting it to report collisions.

The underlying Physics engine (PhysX) can handle a lot of these things very efficiently, though it really depends on your scene. If there are tons of OnTrigger events going off every frame, your issue would be more about all the callbacks happening than anything.

No need to worry about performance really until you notice a performance issue. Just use the profiler to see how things are shaping up as you go.

Comment
Add comment · Show 1 · 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 Android Matt · Mar 04, 2013 at 11:04 PM 0
Share

Thanks, I think this is one viable option.

Also, the advice about the performance is a sensible one. While it's a reasonable idea to be aware of potential performance impacts before you hit them, if the game works the way it's coded then I suppose optimization isn't needed for the most part.

I should add that I am trying out the Physics.OverlapSphere now which might give me a little more control over the trigger since I can call that as and when I need and not worry about checking for a trigger that I have accidentally turned off elsewhere in my code.

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

Collision Detection without a RigidBody 2 Answers

Can't figure out how to use multiple triggers in single scene 1 Answer

OnTriggerEnter (JS) 1 Answer

Null reference that isn't null 2 Answers

The name 'Joystick' does not denote a valid type ('not found') 2 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