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 Anymeese · May 26, 2014 at 10:30 PM · multiplayerplayeronline

How to implement "Owner" (as in P1 or P2)?

I'm working on a 1v1 online game and being my first multiplayer and first online game, I'm not really sure the best way to mark which base is which, which units, etc are owned by player 1 and by player 2. For example the player should be able to buy units when they click on their own base but not the opponent's base. Should I put all the units and buildings owned by player 1 in a Layer called Player 1 Owned, put them with a Tag, use a script variable (bool or enum), or what? I'm just not sure what the best way would be

The player needs to be able to select his own base, select his own units, and attack enemy units. Those are the 3 key reasons I need to differentiate between owning player

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

Answer by Kiwasi · May 27, 2014 at 12:32 AM

All of your methods mentioned will work. It depends what else you are using.

Tags is probably the easiest, but remember a GameObject can only have one tag. So if you rely on tags to identify ownership you can't use them for anything else. But see this

Layers could also work. However you run into the same problem with each GameObject only having one layer.

Script variables work, but will require you to place a script on each GameObject. There are multiple options to choose from here too.

  • Create a enum that keeps track of the owner

  • Create a GameObject that represents the owner and store a reference to the owner on each script

Comment
Add comment · Show 3 · 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 Anymeese · May 27, 2014 at 03:16 AM 0
Share

I think one of the main thing I'm having trouble wrapping my head around is whether I should be in ONE scene or one per player. Surely both players will be in the same singular scene when they play the match right? But then how can I code fog of war/vision for each player that the other can not see?

Also, thank you very much for your help :)

avatar image Kiwasi · May 27, 2014 at 04:20 AM 0
Share

$$anonymous$$ulti player and networking is a complex topic. I have never attempted it myself.

Typically both players will work in separate but identical scenes generated on the local machine. The only data shared between them is when something changes.

avatar image Anymeese · May 27, 2014 at 05:11 AM 0
Share

this is what i needed to know, thanks! Now I can start putting it together knowing its 2 separate scenes :)

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

22 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

Related Questions

Php Character list/sessions 0 Answers

Multiple player spawnpoints 0 Answers

Network multiplayer chess/battleship game cameras 2 Answers

Entering multiple variables into a function 1 Answer

Changing to online sceen in multiplayer 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