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 manGo29 · Jul 29, 2013 at 04:56 PM · networkingarrayplayerrpclocal

Assigning Player Numbers

I'm going out of my mind trying to set a global array inside my network controller which assigns an integer to players when they join the game.

I've read so many docs and tutorials about networking and RPCs that my head hurts. Clearly networking isn't for me; but I still need to get this working so I can [finally] continue.

What I want to do seems very simple to me: I have a single empty game object with my network manager script and a network view attached (state sync is set to 'off' and observed is 'none' because the data is being sent thru RPC calls). The network manager script handles all the player object instantiations as expected. When a player joins, I want the network manager to:

  • check an array which holds all the player slots,

  • find the first open slot,

  • then set the player object's player number (a public integer variable) to that open slot thru an RPC call,

  • and finally set that open slot to full, so players don't get instantiated as the same number.

Maybe it's my own frustration at failing so hard at this, but it blows my mind that I can't find an internal call to return the local player's player number as the int they were assigned when they joined. Just to illustrate: the player number will be referenced pretty frequently-- until I got stuck here, I was using the player numbers to set alliances:

 if(localPlayerController.alliances[playerNumberOfTarget]==AllianceClassStatus.enemy)
 //Allow Player to attack.

I hope I'm not letting my frustration seep into this post too much. And again, I apologize if I am missing an internal call that I can use, but I've read every doc I could find. I just can't wrap my head around networking, and I'll be very happy to get this tied down.

Edit:: And to clarify, I'm looking for a way to make an array of anything that I can reference later by the array index; such as

 player[1]==<GameObject> or <NetworkPlayer> or <Network.IpAddress>, etc.
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

0 Replies

· Add your reply
  • Sort: 

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

15 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

Related Questions

Target = NetworkedMe 1 Answer

Identifying local player issue 0 Answers

Send array of transforms via RPC. [C#] 1 Answer

Networking: How do I send player positions? 2 Answers

Waypoints and out of range problem.[Solved] 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