[Command]
public void CmdSetTracker()
{
// get a client id first
NetworkIdentity m_Identity = GetComponent<NetworkIdentity>();
// int clientId = ...;
int clientID = m_Identity.connectionToClient.connectionId;
// Get client position and rotation
Tracker tracker = new Tracker
{
Position = gameObject.transform.position,
Rotation = gameObject.transform.rotation
};
// Set position and rotation of the player to the tracker
_lookup[clientID] = tracker;
}
[Command]
public void CmdTeleportRequest()
{
NetworkIdentity m_Identity = GetComponent<NetworkIdentity>();
// int clientId = ...;
int clientID = m_Identity.connectionToClient.connectionId;
// Fetch the client id
// Grab the previous tracker:
Tracker tracker;
if (!_lookup.TryGetValue(clientID, out tracker))
{
// No tracker available. Do nothing, or send no tracker rpc to the client
return;
}
gameObject.transform.position = tracker.Position;
// Grab the player and set the position / rotation based on the tracker object
}
With that i got no error on console but the client doesn’t warp 
Since some days i got this error
A connection has already been set as ready. There can only be one.
UnityEngine.Networking.NetworkIdentity:UNetStaticUpdate()
Check screenshot, i don’t know why I have that, can it make some problem for the client?
I heard that can be a problem with the networkmanager script, but i didn’t find out the solution…
Here NetworkManager script:
using System;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.Networking;
using UnityEngine.Networking.Match;
public class MyLobby : NetworkManager {
public GameObject LobbyOption;
public GameObject TitleScreen;
private bool TitleBool;
public enum Selection { none, minato, saitama, goku, war };
public Selection currentSelect;
private float nextRefreshTime;
// public GameObject MinatoButton;
// public bool minato;
GameObject playerselected;
public GameObject MinatoPlayer;
// public GameObject SaitamaButton;
// public bool Saitama;
public GameObject SaitamaPlayer;
// public GameObject GokuButton;
// public bool Goku;
public GameObject GokuPlayer;
// public GameObject WarButton;
// public bool War;
public GameObject WarPlayer;
public void StartHosting()
{
StartMatchMaker();
matchMaker.CreateMatch("Jasons Match", 4, true, "", "", "", 0, 0, OnMatchCreated);
}
private void OnMatchCreated(bool success, string extendedInfo, MatchInfo responseData)
{
base.StartHost(responseData);
RefreshMatches();
}
private void Update()
{
if (Time.time >= nextRefreshTime)
{
RefreshMatches();
}
if(currentSelect == Selection.war)
{
playerselected = WarPlayer;
}
if (currentSelect == Selection.minato)
{
playerselected = MinatoPlayer;
}
if (currentSelect == Selection.saitama)
{
playerselected = SaitamaPlayer;
}
if (currentSelect == Selection.goku)
{
playerselected = GokuPlayer;
}
// currentSelect = MinatoButton.GetComponent<CharacterSelectionScreen>().currentSelect;
// Goku = GokuButton.GetComponent<CharacterSelectionScreen>().GokuSelected;
// Saitama = SaitamaButton.GetComponent<CharacterSelectionScreen>().SaitamaSelected;
// War = WarButton.GetComponent<CharacterSelectionScreen>().WarSelected;
}
private void RefreshMatches()
{
nextRefreshTime = Time.time + 5f;
if (matchMaker == null);
StartMatchMaker();
matchMaker.ListMatches(0, 10, "", true, 0, 0, HandleListMatchesComplete);
}
public void JoinMatch(MatchInfoSnapshot match)
{
if (matchMaker == null)
StartMatchMaker();
matchMaker.JoinMatch(match.networkId, "", "", "", 0, 0, HandleJoinedMatch);
}
private void HandleJoinedMatch(bool success, string extendedInfo, MatchInfo responseData)
{
StartClient(responseData);
}
private void HandleListMatchesComplete(bool success, string extendedInfo, List<MatchInfoSnapshot> responseData)
{
AvaibleMatchesList.HandleNewMatchList(responseData);
}
public override void OnServerAddPlayer(NetworkConnection conn, short playerControllerId)
{
TitleScreen.SetActive(false);
LobbyOption.SetActive(true);
GameObject player = (GameObject)Instantiate(playerPrefab, Vector3.zero, Quaternion.identity);
NetworkServer.AddPlayerForConnection(conn, player, playerControllerId);
}
// if (team == 1)
// { player.GetComponent<MinatoController_Net>().team = 1; }
//int team = TeamHandler.GetComponent<TeamHandler>().team;
public void Wargreymon()
{
// LobbySelect.GetComponent<MyLobby>().currentSelect = war;
currentSelect = Selection.war; // changes currentSel to Up.
}
// MinatoButton.GetComponent<CharacterSelectionScreen>().MinatoSelected = false;
// SaitamaButton.GetComponent<CharacterSelectionScreen>().SaitamaSelected = false;
// GokuButton.GetComponent<CharacterSelectionScreen>().GokuSelected = false;
// WarSelected = true;
public void Minato()
{
currentSelect = Selection.minato; // changes currentSel to Up.
// WarButton.GetComponent<CharacterSelectionScreen>().WarSelected = false;
// SaitamaButton.GetComponent<CharacterSelectionScreen>().SaitamaSelected = false;
// GokuButton.GetComponent<CharacterSelectionScreen>().GokuSelected = false;
// MinatoSelected = true;
}
public void Goku()
{
currentSelect = Selection.goku; // changes currentSel to Up.
// WarButton.GetComponent<CharacterSelectionScreen>().WarSelected = false;
// MinatoButton.GetComponent<CharacterSelectionScreen>().MinatoSelected = false;
// SaitamaButton.GetComponent<CharacterSelectionScreen>().SaitamaSelected = false;
// GokuSelected = true;
}
public void Saitama()
{
currentSelect = Selection.saitama; // changes currentSel to Up.
// WarButton.GetComponent<CharacterSelectionScreen>().WarSelected = false;
// MinatoButton.GetComponent<CharacterSelectionScreen>().MinatoSelected = false;
//// GokuButton.GetComponent<CharacterSelectionScreen>().GokuSelected = false;
//SaitamaSelected = true;
}
public void PlayerChoosed(NetworkIdentity player)
{
var conn = player.connectionToClient;
var newPlayer = Instantiate<GameObject>(playerselected);
LobbyOption.SetActive(false);
Destroy(player.gameObject);
NetworkServer.ReplacePlayerForConnection(conn, newPlayer, 0);
}
}