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 Caps · May 06, 2011 at 05:37 AM · playernetworkclienttrack

Create and Keep Track of Player LIst in Server...

Hi guys,

Ok, for a few days now Ive been trying to create a client list on a server. Now, I know this is probably not too difficult but since Im no experienced programmer its just being kind of difficult! IIve read some tutorials (Leepos and the Networking) but since most of the code is in js and part of their own project its being very complicated for me to grasp the functionality and stick it to my code... I kind of understand the concept of how it works though.

The reason Im trying manage client list is because of all the issues using network.instantiate and destroy.

So, basically the design Im using is clients control themselves (movement, firing etc.).

Each client instantiates itself (game character) and sends an RPC to all (buffered) wich instantiates a clone of that game character with respective ID locally on each other client.

What I want is to be able to create on server, a list o players, with their names and ID and have the server manage the instantiation and destroying the clients that arrive or leave (instead of using buffered RPCs).

I just dont know where to start. Heres what I have untill now:

using UnityEngine; using System.Collections;

public class Client_Start_Script : MonoBehaviour { public Transform playerPrefab; public Transform start_camera_Prefab;
public Camera client_camera; private Vector3 player_spawn_position; private Vector3 server_spawn_position;

public string player_name = null;

//Server-only playerlist public ArrayList playerList = new ArrayList();

public class PlayerNode { public string player_name; public NetworkPlayer networkPlayer; }

void Start ()

{ server_spawn_position = new Vector3(-3, 3,-20); player_spawn_position = new Vector3(-3,20,-20); Instantiate(start_camera_Prefab, server_spawn_position, transform.rotation);

}

//Server function

void OnServerInitialized() { PlayerNode newEntry = new PlayerNode(); newEntry.player_name=player_name; newEntry.networkPlayer=Network.player; playerList.Add(newEntry);

}

void OnGUI() {

     if (Network.isClient)
     {
         if (GUILayout.Button("SpawnPlayer")) 

         {

         //Network.Instantiate(playerPrefab, player_spawn_position, transform.rotation, 0);
         NetworkViewID viewID = Network.AllocateViewID();
         networkView.RPC("SpawnPlayer", RPCMode.AllBuffered, viewID, transform.position);
         }
     }

}

[RPC] void SpawnPlayer(NetworkViewID viewID, Vector3 location)

{ Transform clone; clone = Instantiate(playerPrefab, location, Quaternion.identity) as Transform; NetworkView nView; nView = clone.GetComponent<NetworkView>(); nView.viewID = viewID;

}

}

Comment
Add comment · Show 4
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 Caps · May 10, 2011 at 03:29 AM 0
Share

Anyone??? This can't be so hard...

avatar image B-rad · Nov 05, 2012 at 08:59 PM 0
Share

I'm trying to figure out pretty much the same thing. Hopefully someone will help us out, but I'll let you know if I find out anything.

avatar image coffiarts · Jan 12, 2013 at 12:36 PM 0
Share

I've been figuring out the same, and after 3 days of struggling, I believe that I've found a decently solid solution. I'll try to describe it a bit better soon as an answer.

Let's say for now: I managed to maintain a players array on the server that keeps track of every client by his player name and GUID. This array will then (later) be used to store more sophisticated player information (like scores etc.).

Note that my solution still relies on some RPC calling, but the server has do$$anonymous$$ance over the list. This is especiallay helpful for tracking improper client logoffs (such as crashes or users simply closing the window). If such things happen, the server will automatically unregister the player from the list.

avatar image Madswint · Jan 13, 2014 at 03:15 PM 0
Share

schnaddlbraag, do you still have the scripts?

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

3 People are following this question.

avatar image avatar image avatar image

Related Questions

Player falls through plane/floor (Multiplayer) 1 Answer

Trying to manage local network users. (5.1.0) 1 Answer

Methods Repeats for each New Player connected 0 Answers

Multiplayer|3dText PlayerName 1 Answer

UNET NetworkServer.Spawn intermittently not called on clients 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