/// <summary> /// When the client receives a P2P message of their spawn point, /// this will move them to that location before sending their vehicle /// to the host. This will call the function that spawns the local /// vehicle. /// </summary> /// <param name="packet">The message sent over the network</param> public static void RequestSpawn_Result(Packet packet) //Run by Clients Only { Debug.Log("The host has sent back our spawn point"); Message_RequestSpawn_Result result = (Message_RequestSpawn_Result)((PacketSingle)packet).message; Debug.Log($"We need to move to {result.position} : {result.rotation}"); GameObject localVehicle = VTOLAPI.GetPlayersVehicleGameObject(); if (localVehicle == null) { Debug.LogError("The local vehicle was null"); return; } localVehicle.transform.position = result.position.toVector3; localVehicle.transform.rotation = result.rotation; PlayerVehicle currentVehiclet = PilotSaveManager.currentVehicle; localVehicle.transform.TransformPoint(currentVehiclet.playerSpawnOffset); if (carrierStart) { if (!carrierFound) { storedSpawnMessage = packet; return; } } SpawnLocalVehicleAndInformOtherClients(localVehicle, localVehicle.transform.position, localVehicle.transform.rotation, result.vehicleUID, result.playerCount); localUID = result.vehicleUID; Time.timeScale = 1.0f; }
/// <summary> /// When the client receives a P2P message of their spawn point, /// this will move them to that location before sending their vehicle /// to the host. /// </summary> /// <param name="packet">The message sent over the network</param> public static void RequestSpawn_Result(Packet packet) //Clients Only { Debug.Log("The host has sent back our spawn point"); Message_RequestSpawn_Result result = (Message_RequestSpawn_Result)((PacketSingle)packet).message; Debug.Log($"We need to move to {result.position} : {result.rotation}"); GameObject localVehicle = VTOLAPI.instance.GetPlayersVehicleGameObject(); if (localVehicle == null) { Debug.LogError("The local vehicle was null"); return; } localVehicle.transform.position = result.position.toVector3; localVehicle.transform.rotation = Quaternion.Euler(result.rotation.toVector3); SendSpawnVehicle(localVehicle, result.position.toVector3, result.rotation.toVector3, result.vehicleUID); localUID = result.vehicleUID; }