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 toishaanpatel · Jul 10, 2020 at 03:28 PM · triggersperformance optimizationracing gamepositions

Is too many trigger colliders and function calls very bad for game performance?

I am making a karting game and for the positioning system, I am using about 400 trigger colliders placed very close to each other around the track, and everytime the player or opponent enters one of them, a value increments in their script. Then every 0.2 seconds, a function call happens in the race manager script, which sorts a LIST (not array) of references (scripts) to each player/opponent, according to that value being incremented in the race. The index+1 of every player in the list represents their position. The positioning system works fine, and I am testing it with 3 players currently. I did not notice any frame rate drops when testing the game, but I was wondering if this is a bad idea and if I should go for another solution. Earlier, I tried the three way sort method where it first tries to organize players by lap they are on, then by the value I described, and then by the distance to the next checkpoint if two players are on the same upcoming checkpoint. I avoided this because I heard that vector3.distance can be expensive if called too much.

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

Answer by Magso · Jul 10, 2020 at 04:30 PM

"400 trigger colliders placed very close to each other around the track, and everytime the player or opponent enters one of them, a value increments in their script."

I also used to do this and yes the performance will suffer. You're better off using only a few waypoints and using the Vector3.Distance method, multiply the returned number by the waypoint number and sort the array lowest to highest.

Comment
Add comment · Show 3 · 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 toishaanpatel · Jul 10, 2020 at 05:42 PM 0
Share

Oh, ok. Is the method call to the OnTriggerEnter very heavy? If so, then I will change the method I use for positions

avatar image toishaanpatel toishaanpatel · Jul 10, 2020 at 05:45 PM 0
Share

Because I was having issues with the vector3.distance comparison thing. I just used this method since it is an easy way to do it. However, I will revisit the vector3.distance method and try to make it work.

avatar image Magso toishaanpatel · Jul 10, 2020 at 05:59 PM 0
Share

Vector3.Distance isn't heavy, it's returning a length of a vector as a float as opposed to OnTriggerEnter which is using physics to return a collider type.

Edit: technically OnTriggerEnter returns void, the collider is the parameter given by the physics engine.

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

134 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 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 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 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 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 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 avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

Why Trigger colliders costs more than non trigger ones? 0 Answers

Make an object a trigger? 1 Answer

What is the trigger? 2 Answers

Build and Run is breaking my triggers! 1 Answer

Some problems with triggers? 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