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
2
Question by Twanger · May 16, 2011 at 04:28 PM · gamelogic

Where does C# game logic go?

Hello.

I'm having difficulty finding out where my Game Logic goes in Unity.

I understand that object-based AI, such as moving a game object across the screen over multiple frames, is done via attaching scripts to render objects.

But what about game logic that isn't tied to any particular object? Is there a "main()" or something where I can put code that orchestrates all visual objects, maintains game state, etc.?

Thanks, BT

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 QuestionBro · May 16, 2011 at 04:37 PM

You can just create an empty gameobject and simply place scripts on it to handle things such as GUI, game state, and anything else you might want to control(player stats or generation of the map, or even things like day and night cycles). Unless I am reading your question wrong is that along the lines of what you were wondering?

Comment
Add comment · Show 8 · 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 Twanger · May 16, 2011 at 04:39 PM 0
Share

So create an empty object in the scene, attach my GameLogic() class/script to it, then do all game logic from within its Update() function?

avatar image Twanger · May 16, 2011 at 04:42 PM 0
Share

Typically what goes in such a class is overall game state for game save purposes, etc. It would handle anything that's more of a "global" event, such as creating new bugs at the top of the screen in Centipede. Once those things are created they run on their own, but only a higher-level intelligence knows WHEN to create them.

avatar image QuestionBro · May 16, 2011 at 04:48 PM 0
Share

Yes that is essentially what you do, you do not need to put all the logic in one scripts update, you can split things up into manageable classes, but using empty gameobjects for controlling basic functions in your game such as states is fine. I usually see in some of the larger projects I have worked on / seen have a "general scripts" empty gameobject in them for just such a purpose. Hope that helped ya out.

avatar image Joshua · May 16, 2011 at 04:51 PM 0
Share

Or you just throw everything on the main cam :)

avatar image Twanger · May 16, 2011 at 04:51 PM 0
Share

Yep, thanks! Will just take some getting used to. We have some legacy C++ game logic as well as some device drivers we must communicate with, so it will be interesting. Right now I'm just trying to nail down to workflow to ensure feasibility.

Show more comments

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

No one has followed this question yet.

Related Questions

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

Save Position script. 2 Answers

Script for tank fire 0 Answers

I need help with a script(brauche hilfe mit einen Script) 0 Answers

animation.Play (MissingComponentException: There is no 'Animation' attached to.. 2 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