So I am busy with a plugin that will teleport players to each other to a random spawn point, this is for a Duel plugin.
My issue now is after teleporting the players they are facing random directions, I would like to rotate the players to face each other. Does anyone have any idea to do this?
Solved Rotate WorldPlayerEntity on teleportation
Discussion in 'Hurtworld Development' started by Pho3niX90, Feb 22, 2016.
-
Have a look at NetworkEventRespawn.Execute(), this sets the player rotation.
-
[DOUBLEPOST=1456245274,1456209157][/DOUBLEPOST]Okay this is what I have tried, but doesn't seem to be working. I am clearly missing something
playerEntity1.transform.position = Vector1;
playerEntity2.transform.position = Vector2;
playerEntity1.transform.LookAt(Vector2);
playerEntity2.transform.LookAt(Vector1); -
Not sure if works, but you can try and tell me the results
You get each player sessions and find both FPSInputControllerServer from the players:
Code:FPSInputControllerServer fps1 = player1Session.WorldPlayerEntity.GetComponent<FPSInputControllerServer>(); FPSInputControllerServer fps2 = player2Session.WorldPlayerEntity.GetComponent<FPSInputControllerServer>();
Code:Vector3 vector1 = (player2Pos - player1Pos).normalized; Vector3 vector2 = (player1Pos - player2Pos).normalized;
Code:Quaternion lookRotation1 = Quaternion.LookRotation(vector1); Quaternion lookRotation2 = Quaternion.LookRotation(vector2);
Code:fps1.ResetViewAngleServer(lookRotation1); fps2.ResetViewAngleServer(lookRotation2);
-