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 Levantez · Apr 20, 2013 at 01:31 PM · collisioncolliderspeedphysicprocessing

Collider collision processing speed

Hi, I'm creating a stealth game at the moment.

The sequence for Player Detection is

 if(PlayerInRange())
 {
      TurnOnCollision();
 }

 OnTriggerEnter()
 {
      CheckIfPlayerHitCollider();
 }

I was worrying that the processing will be slowed down if the collider will be ON all the time since it will hit many collider objects beside Player. Thus, I made it so that the Detection mesh collider will be activated only if the player came within certain range.

So, I was wondering on how heavy the OnTrigger-related functions are.

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
Best Answer

Answer by Aaron Winterhoff · Apr 20, 2013 at 03:01 PM

This requires a bit more information.

Does TurnOnCollision therefore turn on the collider itself?

Is the "DetectionMeshCollider" a Unity sphere collider, or a mesh that you've made? Mesh colliders are generally more intensive than one of Unity's built-in colliders (sphere,box, capsule etc).

That said, if you're using a unity collider, unless you have a huge amount of enemies searching for an enemy, you should be fine.

These things take place in the background of unity, and are ultra-fast physics calculations. The call OnTriggerEnter () gets called whenever something Enters the collider, and if you have a OnTriggerEnter () call, then it's going to be doing the check anyway. Long story short, Unity is faster than we are.

If you look at their documentation itself, you can see that they ( point 5 ) actually refer to your exact problem. Their solution is to use Triggers, not check a distance. If you're checking a distance as well, then you're just doubling up on Unity's workload.

Unity Documentation Example

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 Levantez · Apr 21, 2013 at 02:52 PM 0
Share

Yes, TurnOnCollision() was suppose to turn on the Collider.

avatar image
0

Answer by Jazzer008 · Apr 20, 2013 at 02:47 PM

Personally, I'm not a big fan of triggers. It might be the way I'm using them, but sometimes they don't seem to function without issues.

I think it would be less 'heavy', to grab the positions of each objects and check the distance between them.

 if(Vector3.Distance(object1.transform.position,object2.transform.position) <= minimumDistance){
       TurnOnCollision(); 
   }
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

13 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

Related Questions

Can an object to transfer to another as it increases your speed? 1 Answer

Collision update speed 0 Answers

Unity Height Glitch (explained) 1 Answer

Maintaining speed after collision 0 Answers

Object moving too fast, so that the collider does not work (C#) 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