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 Cleite · Dec 22, 2016 at 04:00 PM · turn-basedplayers

How do I decide who goes first in a turn-based game?

I am making a turn-based game, and as most turn-based games, there has to be a first player. I want to be able to resolve which player is going first, and I'm going to be particular about how I want to do it.

I could make a GameMaster object whose only purpose is to tell one of the PlayerObjects "You go first". But that's not how one usually plays a game in the real world. The players would not be told by an outsider who goes first, they would agree among themselves.

Second, I want the players to be entirely symmetrical. That is, I don't want to have one player have a FirstPlayerscript, I want them both to have the exact same script. This also goes for anything like a`public bool`. That's because that's still something beyond the players deciding who goes first, like the biggest kid always goes first because he's the biggest, and that feels wrong to me. Therefore, the players should have identical scripts and identical public fields.

What I want is for the PlayerObjects to comminucate in some way and decide on a beginner in a completely fair manner. However, note that I'm not saying that there should be an even split over the course of many games. For instance, I have no control over what order their Start() methods are called. So if Unity decides that the one who's on top in the Hierarchy is called first every tuesday and otherwise it's the one on the bottom, that's allright. I just want the players to be as equal to one another as the editor will let me.

Is there a nice way of deciding who goes first, all else being equal?

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 oswin_c · Dec 22, 2016 at 04:37 PM

That's fine -- you don't need to do anything with the player script.

Simply have something like, on the player script...

 public void TakeTurn()
 {
     DoTurn();
 }

Then, for example, on your GameMaster script, you could randomly rearrange the list of players, then call them in order. I had written up an example algorithm for doing this but unfortunately I have to leave and don't have time to finish it. If you get stuck and would like one, let me know.

On the GameMaster script, you could order the players in whatever order you like with whatever algorithm you like, then simply call...

 void NextTurn()
 {
     ....
     NextPlayer.TakeTurn(); 
 }

The player script would have nothing whatsoever to do with how they are ordered, only have a public TakeTurn() function, identical to all the others, that the GameMaster script calls when necessary.

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 Cleite · Dec 22, 2016 at 05:43 PM 0
Share

This is still not the players themselves agreeing on who goes first though. This is an authoroty figure (i.e. the Game$$anonymous$$aster) telling them who goes first. It doesn't matter that (s)he rolls a die to decide it. If I can just solve this little conundrum in a nice manner, I won't have need for a Game$$anonymous$$aster, since the game is simple enough that all the elements can just take care of themselves. I want to try to make this game without having to have a Game$$anonymous$$aster at all, and in that process, I stumbled upon the puzzle I posted above.

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

84 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

Related Questions

Tile-based Enemy AI issue 0 Answers

StreamingAssets: allow players to edit sprites? 0 Answers

Best way to implement the server-side of a online turn based game? 0 Answers

C# Stuck on creating my Turn based battle system 0 Answers

Pull Playfab users list 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