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 burzum · Mar 06, 2012 at 08:49 AM · globalspace

How to manage a round based game?

As far as I understood scripts in unity are always (?) attached to game objects. But how can I create a script that observes the current running round or level of a game and detect changes in it's state?

Like I want to have for example 3 players, when one finishes his move the next player should be able to move his pawn. Would I attach this script also to some game object?

Also how do I bring all the UI stuff together? Like my 3 players are in the same team and their pawns character portraits should be shown in a list. If there are only two show two, if there are three, show three.

I'm mostly interested in how I an "connect" all these things.

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

Answer by save · Mar 06, 2012 at 09:09 AM

The easiest approach is to have a manager of some sort. The manager is just a script attached to a GameObject which preferably doesn't destroy on loading new levels. All variables and functions could be static inside the manager so you just have to call something like: GameManager.NextPlayerMove();

//Inside the script called GameManager you can have something like:

static var currentPlayer : int = 0; static var activePlayers : int = 3;

static function NextPlayerMove () { if (currentPlayer<activePlayers) { currentPlayer++; } else { currentPlayer = 0; } }

You'd increase the activePlayers when somebody joins or drops out in the same way via a function.

Regarding the UI stuff you'd use a for-loop for each player.

function OnGUI () {
    for (var i : int = 0; i < GameManager.activePlayers; i++) {
        //Each player's avatar here
    }
}

Check out the GUI Scripting Guide to see what you can do.

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 mesho · Mar 06, 2012 at 09:08 AM

Firstly you can attach all the scripts to an Empty game object and then call it "Manager" for example , and for connecting you can use the SendMessage from Unity , it helps you a lot to send orders from a script to another , and sure because your numbers changes in addition to lots of factors you will use a ( Static Variables ) ; it is a pretty rough answer but it is the main guide lines which you need, if you need a big explanation to any of that , just tell here & i`ll give

cheers M:)

Comment
Add comment · Show 2 · 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 save · Mar 06, 2012 at 09:15 AM 0
Share

It's a good approach except I'd try to leave Send$$anonymous$$essage out if I didn't have to talk between different scripting languages for instance. Send$$anonymous$$essage is a bit slower than calling static functions or variables directly from another script.

avatar image burzum · Mar 07, 2012 at 09:43 PM 0
Share

Thanks for your answer! But I can't flag both as correct so I've picked the other one that is a little more detailed.

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

want open source unity3d game + explaination document 0 Answers

Finding a local position matching a global position in an individually rotated hierarchy 2 Answers

How to make an adaptive mobile game? 0 Answers

How does GetRelativeVector work? 1 Answer

Best way to handle high number of usable/pickable objects? 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