function OnPlayerConnected(player: NetworkPlayer) {
Debug.Log("I show up!");
// send the connected ply an unique ID (Time.time) and name.
// variables will be placed in a component with NetworkView, other
// players will also get these details eventually coz of this.
networkView.RPC("assignUserDetails", player, Time.time, "testuser");
}
function assignUserDetails(uniqueID : int, playerName : String, info : NetworkMessageInfo) {
var plLocal = GameObject.Find("playerlocal");
plLocal.GetComponent(char_mydetails).myID=uniqueID;
plLocal.GetComponent(char_mydetails).myName=playerName;
GameObject.Find("playerlocal/test").GetComponent(TextMesh).text=playerName;
}
The code above is placed on an object that has a network view (no state sync, no observed component). But, the RPC is never executed.
What I am trying to accomplish:
- the server receives onPlayerConnected
- sends an RPC to the connected player
- the connected player that receives the RPC places user details in the
local player object. - The component where these user details are stored contains a network
view, so as soon as his/her name and user id are stored, the other players should have this information as well.
So (3) doesn’t work…
Thanks for your patience! We need a scripting->networking forum