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 /
This question was closed Nov 22, 2013 at 05:21 AM by Eric5h5 for the following reason:

Question is off-topic or not relevant

avatar image
0
Question by aronatvw · Nov 22, 2013 at 03:41 AM · optimizationgetcomponentmemoryorganization

Random question about getcomponent

So I know its often recommended to keep scripts performing different operations as separate scripts for organizational reasons. My question is why, being that it would make it more likely you would have to use functions like getcomponent which is not only costly but also tedious to do especially from different objects. Is it recommended to just use your own discretion? Opinions are welcome or any tips and advice to a novice!

Comment
Add comment · Show 1
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 Eric5h5 · Nov 22, 2013 at 05:21 AM 0
Share

This should be posted on the forums, since it's not a specific development question that has an objective answer that can be accepted, it's a discussion question.

1 Reply

  • Sort: 
avatar image
0
Best Answer

Answer by Phong · Nov 22, 2013 at 05:04 AM

I would say the benefits of the component model are:

  • Reusable modules of code

  • Avoiding code duplication

  • Ability to develop complex behavior by building it out of smaller parts

  • Loose coupling between code modules

Working with components is like building with Lego. Each individual brick doesn't do much and isn't very sophisticated. But when combined with other bricks then something wonderful emerges. You can take the whole thing apart and make something different or add new bricks to give the creation new behavior (wheels, wings etc...).

For example consider AI code to drive a car. If you do it right you should be able to apply the same AI behavior to different vehicle rigs by just adding the AI components to the new car game objects. If you don't like the AI behavior then you remove the AI components and add different AI components, perhaps something purchased from the asset store. When developing your next game it is easy to re-use the AI scripts from your previous game. You could sell the AI scripts as a package in the asset store.

When working with one monolithic script per game object then it is MUCH harder to reuse code and avoid duplication.

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

Follow this Question

Answers Answers and Comments

18 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

Related Questions

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

How to delegate events from one GameObject to another? 1 Answer

How do I efficiently maintain a constantly-changing list without triggering GC? 2 Answers

UI-based game memory and performance issue. 1 Answer

Sprite-based animation - mobile memory issue 0 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