@@ -136,7 +136,7 @@ public bool IsClientConnected
136
136
/// <summary>
137
137
/// The callback to invoke during connection approval
138
138
/// </summary>
139
- public Action < byte [ ] , uint , Action < uint , bool > > ConnectionApprovalCallback = null ;
139
+ public Action < byte [ ] , uint , Action < uint , bool , Vector3 , Quaternion > > ConnectionApprovalCallback = null ;
140
140
/// <summary>
141
141
/// The current NetworkingConfiguration
142
142
/// </summary>
@@ -586,13 +586,14 @@ public void StopClient()
586
586
/// <summary>
587
587
/// Starts a Host
588
588
/// </summary>
589
- public void StartHost ( )
589
+ public void StartHost ( Vector3 ? pos = null , Quaternion ? rot = null )
590
590
{
591
591
if ( isServer || isClient )
592
592
{
593
593
Debug . LogWarning ( "MLAPI: Cannot start host while an instance is already running" ) ;
594
594
return ;
595
595
}
596
+
596
597
ConnectionConfig cConfig = Init ( true ) ;
597
598
if ( NetworkConfig . ConnectionApproval )
598
599
{
@@ -622,7 +623,7 @@ public void StartHost()
622
623
623
624
if ( NetworkConfig . HandleObjectSpawning )
624
625
{
625
- SpawnManager . SpawnPlayerObject ( netId . GetClientId ( ) , 0 ) ;
626
+ SpawnManager . SpawnPlayerObject ( netId . GetClientId ( ) , 0 , pos . GetValueOrDefault ( ) , rot . GetValueOrDefault ( ) ) ;
626
627
}
627
628
628
629
if ( OnServerStarted != null )
@@ -952,7 +953,7 @@ private void HandleIncomingData(uint clientId, byte[] data, int channelId)
952
953
}
953
954
else
954
955
{
955
- HandleApproval ( clientId , true ) ;
956
+ HandleApproval ( clientId , true , Vector3 . zero , Quaternion . identity ) ;
956
957
}
957
958
}
958
959
}
@@ -1035,7 +1036,7 @@ private void HandleIncomingData(uint clientId, byte[] data, int channelId)
1035
1036
1036
1037
if ( isPlayerObject )
1037
1038
{
1038
- SpawnManager . SpawnPlayerObject ( ownerId , networkId ) ;
1039
+ SpawnManager . SpawnPlayerObject ( ownerId , networkId , new Vector3 ( xPos , yPos , zPos ) , Quaternion . Euler ( xRot , yRot , zRot ) ) ;
1039
1040
}
1040
1041
else
1041
1042
{
@@ -1086,7 +1087,7 @@ private void HandleIncomingData(uint clientId, byte[] data, int channelId)
1086
1087
if ( isPlayerObject )
1087
1088
{
1088
1089
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 ) ) ;
1090
1091
}
1091
1092
else
1092
1093
{
@@ -1161,7 +1162,7 @@ private void HandleIncomingData(uint clientId, byte[] data, int channelId)
1161
1162
float yRot = messageReader . ReadSingle ( ) ;
1162
1163
float zRot = messageReader . ReadSingle ( ) ;
1163
1164
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 ) ;
1165
1166
SpawnManager . spawnedObjects [ netId ] . gameObject . SetActive ( true ) ;
1166
1167
}
1167
1168
}
@@ -1336,7 +1337,7 @@ private void HandleIncomingData(uint clientId, byte[] data, int channelId)
1336
1337
if ( isPlayerObject )
1337
1338
{
1338
1339
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 ) ) ;
1340
1341
}
1341
1342
else
1342
1343
{
@@ -1778,7 +1779,7 @@ private void SyncTime()
1778
1779
}
1779
1780
}
1780
1781
1781
- private void HandleApproval ( uint clientId , bool approved )
1782
+ private void HandleApproval ( uint clientId , bool approved , Vector3 position , Quaternion rotation )
1782
1783
{
1783
1784
if ( approved )
1784
1785
{
@@ -1819,7 +1820,7 @@ private void HandleApproval(uint clientId, bool approved)
1819
1820
if ( NetworkConfig . HandleObjectSpawning )
1820
1821
{
1821
1822
uint networkId = SpawnManager . GetNetworkObjectId ( ) ;
1822
- GameObject go = SpawnManager . SpawnPlayerObject ( clientId , networkId ) ;
1823
+ GameObject go = SpawnManager . SpawnPlayerObject ( clientId , networkId , position , rotation ) ;
1823
1824
connectedClients [ clientId ] . PlayerObject = go ;
1824
1825
}
1825
1826
int sizeOfStream = 17 + ( ( connectedClients . Count - 1 ) * 4 ) ;
0 commit comments