- Home /
 
               Question by 
               Apolo-14 · Dec 19, 2019 at 09:55 AM · 
                c#rotationquaternionclientdedicated-server  
              
 
              How can i sync the rotation of players (clients) on a dedicated server?
Hey Guys,
i am working on a First Person Game and i want to snyc the Rotation between Clients (players). I dont really get how i can get the data of the rotation. For Example, for the position i can use transform.position . Has someone an idea how i get the data of rotation and insert it than to an other player?
Thats how i get the rotation and position of the client (player):
         string position =   player.transform.position.x.ToString().Substring(0, player.transform.position.x.ToString().LastIndexOf(",") + 2) + "|" +
                             player.transform.position.y.ToString().Substring(0, player.transform.position.y.ToString().LastIndexOf(",") + 2) + "|" +
                             player.transform.position.z.ToString().Substring(0, player.transform.position.z.ToString().LastIndexOf(",") + 2);
 
         string rotation =   player.transform.rotation.x.ToString().Substring(0, player.transform.rotation.x.ToString().LastIndexOf(",") + 2) + "|" +
                             player.transform.rotation.y.ToString().Substring(0, player.transform.rotation.y.ToString().LastIndexOf(",") + 2) + "|" +
                             player.transform.rotation.z.ToString().Substring(0, player.transform.rotation.z.ToString().LastIndexOf(",") + 2);
 
         string serverMessage = player.name + ":" + position + ":" + rotation;
 
         //Send Position and Rotation to the Server
         DataSender.SendPositionClientToServer(serverMessage);
And Thats how i would like to insert it:
     public void MoveAllClient(string msg)
     {
         //usernameID + ":" + position + ":" + rotation
         string[] data = msg.Split(':');
 
         string[] dataPositon = data[1].Split('|');
 
         Vector3 position = new Vector3(
            float.Parse(dataPositon[0]),
             float.Parse(dataPositon[1]),
             float.Parse(dataPositon[2]));
 
         string[] dataRotation = data[2].Split('|');
 
         Vector3 rotation = new Vector3(
             float.Parse(dataRotation[0]),
             float.Parse(dataRotation[1]),
             float.Parse(dataRotation[2]));
 
 
         GameObject player = playerList[data[0]];
 
         player.GetComponentInChildren<Rigidbody>().transform.position = position;
         player.GetComponentInChildren<Rigidbody>().transform.rotation = rotation;
     }
If someone has an idea, i would be very happy tho :)
               Comment
              
 
               
              Your answer
 
 
             Follow this Question
Related Questions
Flip over an object (smooth transition) 3 Answers
Object Local Y-Up being forced to be World Y-Up 1 Answer
Rotate relative to Parent 1 Answer
 koobas.hobune.stream
koobas.hobune.stream 
                       
                
                       
			     
			 
                