@@ -136,7 +136,7 @@ public bool IsClientConnected
136136 /// <summary>
137137 /// The callback to invoke during connection approval
138138 /// </summary>
139- public Action < byte [ ] , uint , Action < uint , bool > > ConnectionApprovalCallback = null ;
139+ public Action < byte [ ] , uint , Action < uint , bool , Vector3 , Quaternion > > ConnectionApprovalCallback = null ;
140140 /// <summary>
141141 /// The current NetworkingConfiguration
142142 /// </summary>
@@ -586,13 +586,14 @@ public void StopClient()
586586 /// <summary>
587587 /// Starts a Host
588588 /// </summary>
589- public void StartHost ( )
589+ public void StartHost ( Vector3 ? pos = null , Quaternion ? rot = null )
590590 {
591591 if ( isServer || isClient )
592592 {
593593 Debug . LogWarning ( "MLAPI: Cannot start host while an instance is already running" ) ;
594594 return ;
595595 }
596+
596597 ConnectionConfig cConfig = Init ( true ) ;
597598 if ( NetworkConfig . ConnectionApproval )
598599 {
@@ -622,7 +623,7 @@ public void StartHost()
622623
623624 if ( NetworkConfig . HandleObjectSpawning )
624625 {
625- SpawnManager . SpawnPlayerObject ( netId . GetClientId ( ) , 0 ) ;
626+ SpawnManager . SpawnPlayerObject ( netId . GetClientId ( ) , 0 , pos . GetValueOrDefault ( ) , rot . GetValueOrDefault ( ) ) ;
626627 }
627628
628629 if ( OnServerStarted != null )
@@ -952,7 +953,7 @@ private void HandleIncomingData(uint clientId, byte[] data, int channelId)
952953 }
953954 else
954955 {
955- HandleApproval ( clientId , true ) ;
956+ HandleApproval ( clientId , true , Vector3 . zero , Quaternion . identity ) ;
956957 }
957958 }
958959 }
@@ -1035,7 +1036,7 @@ private void HandleIncomingData(uint clientId, byte[] data, int channelId)
10351036
10361037 if ( isPlayerObject )
10371038 {
1038- SpawnManager . SpawnPlayerObject ( ownerId , networkId ) ;
1039+ SpawnManager . SpawnPlayerObject ( ownerId , networkId , new Vector3 ( xPos , yPos , zPos ) , Quaternion . Euler ( xRot , yRot , zRot ) ) ;
10391040 }
10401041 else
10411042 {
@@ -1086,7 +1087,7 @@ private void HandleIncomingData(uint clientId, byte[] data, int channelId)
10861087 if ( isPlayerObject )
10871088 {
10881089 connectedClients . Add ( ownerId , new NetworkedClient ( ) { ClientId = ownerId } ) ;
1089- SpawnManager . SpawnPlayerObject ( ownerId , networkId ) ;
1090+ SpawnManager . SpawnPlayerObject ( ownerId , networkId , new Vector3 ( xPos , yPos , zPos ) , Quaternion . Euler ( xRot , yRot , zRot ) ) ;
10901091 }
10911092 else
10921093 {
@@ -1161,7 +1162,7 @@ private void HandleIncomingData(uint clientId, byte[] data, int channelId)
11611162 float yRot = messageReader . ReadSingle ( ) ;
11621163 float zRot = messageReader . ReadSingle ( ) ;
11631164 SpawnManager . spawnedObjects [ netId ] . transform . position = new Vector3 ( xPos , yPos , zPos ) ;
1164- SpawnManager . spawnedObjects [ netId ] . transform . rotation = Quaternion . Euler ( new Vector3 ( xRot , yRot , zRot ) ) ;
1165+ SpawnManager . spawnedObjects [ netId ] . transform . rotation = Quaternion . Euler ( xRot , yRot , zRot ) ;
11651166 SpawnManager . spawnedObjects [ netId ] . gameObject . SetActive ( true ) ;
11661167 }
11671168 }
@@ -1336,7 +1337,7 @@ private void HandleIncomingData(uint clientId, byte[] data, int channelId)
13361337 if ( isPlayerObject )
13371338 {
13381339 connectedClients . Add ( ownerId , new NetworkedClient ( ) { ClientId = ownerId } ) ;
1339- SpawnManager . SpawnPlayerObject ( ownerId , networkId ) ;
1340+ SpawnManager . SpawnPlayerObject ( ownerId , networkId , new Vector3 ( xPos , yPos , zPos ) , Quaternion . Euler ( xRot , yRot , zRot ) ) ;
13401341 }
13411342 else
13421343 {
@@ -1778,7 +1779,7 @@ private void SyncTime()
17781779 }
17791780 }
17801781
1781- private void HandleApproval ( uint clientId , bool approved )
1782+ private void HandleApproval ( uint clientId , bool approved , Vector3 position , Quaternion rotation )
17821783 {
17831784 if ( approved )
17841785 {
@@ -1819,7 +1820,7 @@ private void HandleApproval(uint clientId, bool approved)
18191820 if ( NetworkConfig . HandleObjectSpawning )
18201821 {
18211822 uint networkId = SpawnManager . GetNetworkObjectId ( ) ;
1822- GameObject go = SpawnManager . SpawnPlayerObject ( clientId , networkId ) ;
1823+ GameObject go = SpawnManager . SpawnPlayerObject ( clientId , networkId , position , rotation ) ;
18231824 connectedClients [ clientId ] . PlayerObject = go ;
18241825 }
18251826 int sizeOfStream = 17 + ( ( connectedClients . Count - 1 ) * 4 ) ;
0 commit comments