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 /
avatar image
0
Question by LOSTSOUL86 · May 22, 2020 at 11:54 PM · design

Design of game code and classes

Hi I am programming in C# in Unity I created a game and I published it. So i am quite familiar with writing code. I will be starting a new project soon. I need help with learning more about code/game design. I will describe below what I struggle sometimes, I am not certain of and I would like to improve on. I am not sure how to name this subject so I am looking for advice. What course to take what books to read and how this subject is called. I cant really find like a full rulebook about those practice. What I am not certain and sometimes struggle with is:

  • 1

What is the best way to organize classes

  • 2

-what is the best way to split tasks between the classes

  • 3

-When certain task should have separate class

  • 4

-Which game object should hold certain class

  • 5

-Should I control the objects from the class attached to the objects or make external game object with class that will control all objects

  • 6

-Should input class be attached to the game object that it controls or separate object

  • 7

-What is the best way to split tasks between classes

  • 8

-How to pass information from one class to another when needed

As I said I know technically how to implement the functionality of above but how to learn what is the best practice and how to organize it in a proper manner. I know the answers to some degree but I want to learn best approach. Please advise best course to take to learn this. If I search for example "game design" then the course is not really about this kind of things. I know how to make a game but I want to organize classes in a professional way so it will be easier to handle.

I am looking more for answer about how and where to learn this subject. How to search for the answer. I am not looking for someone to answer about best Solutions cause I am.not asking about any specific project. I need the course/book/tutorial that will be comprehensive enough that will give general guidance for multiple solutions. We talking about rather simple games not massive massive ones.

Thanks Wojciech

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

Answer by JerrodStorm · May 23, 2020 at 01:31 AM

The topic you're trying to describe is called software architecture, and the good news is that there are a ton of resources available on that topic. :) A phrase you can search for and that you'll hear a lot when talking about software architecture is "Programming Patterns" or "Design Patterns."


  • The first and best resource I use: Design Patterns, by the Gang of Four

  • There's also a blog I refer to that's specific to how programming patterns can apply to games: Game Programming Patterns. (Pay particular attention to the State pattern. It takes some thinking to apply it to unity's system of MonoBehaviors, but I just used it to completely revamp my player character, and now it's 10 times easier to debug & build new behavior into my player whenever).

  • You'll also want to learn how to read UML diagrams, if you don't already know how. They're a visualization tool that's not specific to any one language. I took a college course that taught me this, but there are plenty of youtube tutorials lying around on this topic. It's really good for planning out solutions ahead of time. It saves time, since you don't have to worry about the specifics of code. Just general structures.


Some other topics/principles you'll want to research:

  • Object Oriented Design

  • Information Hiding

  • Single Responsibility (Each class does ONE job and does it WELL). It's still up to you to decide what consists of one job, but I tend towards smaller, less complex classes in general.

  • Cohesion (Good, and answers 4, 5, and 6)

  • Coupling (Bad, also answers 4, 5, and 6)

  • Composition vs Inheritance (1, 2, 3, and 7)

  • Refactoring (A good reference book for this is Refactoring: Improving the Design of Existing Code)

  • Finite State Machines (This should be familiar to you if you're comfortable with the animation controller).

  • Dependency Injection (this addresses point 8)


The most important thing to remember, though, is not to overuse patterns, or use them just because they're cool. That can backfire just as much as rushing in without a plan.

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

Answer by LOSTSOUL86 · May 23, 2020 at 12:01 PM

Thank you for information that is exactly what I was looking for. I have ordered books already:

  1. Refactoring: Improving the Design of Existing Code 1st Edition by Martin Fowler

  2. Game Programming Patterns 1st Edition by Robert Nystrom

  3. Design Patterns: Elements of Reusable Object-Oriented Software (Addison-Wesley Professional Computing Series) 1st Edition, Kindle Edition by Erich Gamma (Author)

  4. Applying UML and Patterns: An Introduction to Object-Oriented Analysis and Design and Iterative Development (3rd Edition) 3rd Edition by Craig Larman (Author)

  5. UML Distilled: A Brief Guide to the Standard Object Modeling Language (Addison-Wesley Object Technology Series) 3rd Edition, Kindle Edition

Best regards Wojciech

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 JerrodStorm · May 23, 2020 at 12:37 PM 0
Share

Best of luck on your new project!

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

128 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

Related Questions

Collision problems with level design 1 Answer

Confirm Instantiation or Object Confirm it's Instance 2 Answers

Can't create a Factory (Design Pattern) 1 Answer

Do people work on projects together collectively? 1 Answer

Mapping GUIText to Canvas 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