Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 12 Next capture
2021 2022 2023
1 capture
12 Jun 22 - 12 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 /
  • Help Room /
avatar image
0
Question by stew1979 · Sep 01, 2015 at 11:39 PM · scripting problemnewbie

Newbie trying to undestand unity

Hi all My name is stew I am trying to teach my self Unity and making some progress. :) However I have a question regarding object orientated programming; I am current following the Space Shooter tutorial and I am scripting the asteroid What I think I know so far: If an object is required to do something, it must have a script attached to it. From what I understand the script is where you write code to access events and create functions associated with the object the script is link to. My Question: Why would you need to attach multiple scripts to an object when you could write all the code in one script?

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

Answer by Addyarb · Sep 02, 2015 at 12:22 AM

Organization and ease-of-use is the answer to this one. The compiler more-or-less views everything on the object as a single script, but separating scripts by their relative functions (i.e. moving, inventory, animation) helps simplify debugging should you have something wrong with your code.

Is it necessary? Absolutely not. Some people work better with consolidating all of their methods/functions into one giant script. However, Unity staff will typically discourage this from what I've seen in their live lessons/tutorials.

Another less important factor is naming of variables. If you have the speed of your walking, speed of your flying, speed of your camera, etc. all in one script, you'd have to make the names longer and more descriptive - whereas if they were in the "CameraScript" class or the "AnimationParameters" class, you wouldn't have to guess at which speed you were working with.

Good luck with your game programming adventure! Watching the tutorials is the most valuable way to spend your time without question.

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 Darkathion · Sep 02, 2015 at 01:54 AM 0
Share

I agree with this answer if you weren't sure if it was correct its all really just for organisation

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

29 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

Related Questions

Problems with magnet in grid based puzzle game 0 Answers

Can't get roll-a-ball behavior script (my first script) to work... 1 Answer

Changing variable if there are many scripts. 0 Answers

how do I rezolve "look rotation viewing vector is zero"? 1 Answer

RayCast issues 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