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 khellstr · May 19, 2012 at 01:09 PM · gameobjectperformanceupdate

Performance when having Update functions in many gameObjects ?

Is it bad for performance to have Update functions in many gameObjects or should I make one script with Update that loops trough those gameObjects and pass variables to them if needed? And if there is a performance problem difference, how significant it is? If I have circa 50 gameObjects, does it any make difference between those methods.

I have done some coding with AS3 earlier and it was bad to have lot of enterFrame funcitions in different movieClips ( flash equivalent to gameObject and Update).

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

Answer by save · May 19, 2012 at 01:24 PM

No that's no biggie, just make sure to disable objects and components that isn't needed. Some parts of the logic maybe could live inside an invoked repeated function if it's distance checking and such tasks.

Just to give you an idea we have about 50 rigidbodies within a scene with Update- and FixedUpdate-function, animation scripts running alongside and distance checking invoked running on iPhone 3GS devices. Unity is greatly optimized from the beginning, you just have to think about the target limitations.

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 by0log1c · May 19, 2012 at 01:33 PM 2
Share

+1. The overhead of having many Update is infinitesimal if the amount of work is the same but emptying your Update in favor of custom InvokeRepeating() method may make the app considerably faster.

avatar image flamy · May 19, 2012 at 03:01 PM 0
Share

hey save one doubt, if i run 200 lines of code in one update and also run the same amount of code in 5 or 6 files, is there a difference in performance? atleast a bit?

avatar image save · May 19, 2012 at 03:30 PM 0
Share

Yes it will be a performance hit as they all run in the same thread. But it really depends how you've structured it, the amount of code is insignificant to how you actually use it. It's not recommended to run everything within the Update-loop, a couple of if's which executes functions when needed. Lifting code out to functions is really important so you can yield or invoke.

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

6 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

The name 'Joystick' does not denote a valid type ('not found') 2 Answers

FixedUpdate performance doubts 2 Answers

Efficiency of Game Loops 2 Answers

Trigger LateUpdate on inactive gameObjects 2 Answers

How to cycle Vector3 transformations correclty perfomance-wise? 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