diff --git a/Assets/Mirror/Examples/Pong/Scenes/Scene.unity b/Assets/Mirror/Examples/Pong/Scenes/Scene.unity index 21ee86c75..752d64923 100644 --- a/Assets/Mirror/Examples/Pong/Scenes/Scene.unity +++ b/Assets/Mirror/Examples/Pong/Scenes/Scene.unity @@ -200,7 +200,6 @@ GameObject: serializedVersion: 6 m_Component: - component: {fileID: 473997961} - - component: {fileID: 473997960} m_Layer: 0 m_Name: RacketSpawnLeft m_TagString: Untagged @@ -208,18 +207,6 @@ GameObject: m_NavMeshLayer: 0 m_StaticEditorFlags: 0 m_IsActive: 1 ---- !u!114 &473997960 -MonoBehaviour: - m_ObjectHideFlags: 0 - m_CorrespondingSourceObject: {fileID: 0} - m_PrefabInstance: {fileID: 0} - m_PrefabAsset: {fileID: 0} - m_GameObject: {fileID: 473997959} - m_Enabled: 1 - m_EditorHideFlags: 0 - m_Script: {fileID: 11500000, guid: 41f84591ce72545258ea98cb7518d8b9, type: 3} - m_Name: - m_EditorClassIdentifier: --- !u!4 &473997961 Transform: m_ObjectHideFlags: 0 @@ -722,7 +709,6 @@ GameObject: serializedVersion: 6 m_Component: - component: {fileID: 1397990096} - - component: {fileID: 1397990095} m_Layer: 0 m_Name: RacketSpawnRight m_TagString: Untagged @@ -730,18 +716,6 @@ GameObject: m_NavMeshLayer: 0 m_StaticEditorFlags: 0 m_IsActive: 1 ---- !u!114 &1397990095 -MonoBehaviour: - m_ObjectHideFlags: 0 - m_CorrespondingSourceObject: {fileID: 0} - m_PrefabInstance: {fileID: 0} - m_PrefabAsset: {fileID: 0} - m_GameObject: {fileID: 1397990094} - m_Enabled: 1 - m_EditorHideFlags: 0 - m_Script: {fileID: 11500000, guid: 41f84591ce72545258ea98cb7518d8b9, type: 3} - m_Name: - m_EditorClassIdentifier: --- !u!4 &1397990096 Transform: m_ObjectHideFlags: 0 @@ -954,7 +928,7 @@ MonoBehaviour: m_GameObject: {fileID: 1886246549} m_Enabled: 1 m_EditorHideFlags: 0 - m_Script: {fileID: 11500000, guid: 8aab4c8111b7c411b9b92cf3dbc5bd4e, type: 3} + m_Script: {fileID: 11500000, guid: 0aa3018bb284840d6a6d0acee29ab098, type: 3} m_Name: m_EditorClassIdentifier: dontDestroyOnLoad: 1 @@ -972,6 +946,8 @@ MonoBehaviour: autoCreatePlayer: 1 playerSpawnMethod: 1 spawnPrefabs: [] + leftRacketSpawn: {fileID: 473997961} + rightRacketSpawn: {fileID: 1397990096} --- !u!114 &1886246553 MonoBehaviour: m_ObjectHideFlags: 0 diff --git a/Assets/Mirror/Examples/Pong/Scripts/NetworkManagerPong.cs b/Assets/Mirror/Examples/Pong/Scripts/NetworkManagerPong.cs new file mode 100644 index 000000000..589d310eb --- /dev/null +++ b/Assets/Mirror/Examples/Pong/Scripts/NetworkManagerPong.cs @@ -0,0 +1,18 @@ +// custom NetworkManager that simply assigns the correct racket positions when +// spawning players. the built in RoundRobin spawn method wouldn't work after +// someone reconnects (both players would be on the same side). +using UnityEngine; +using Mirror; + +public class NetworkManagerPong : NetworkManager +{ + public Transform leftRacketSpawn; + public Transform rightRacketSpawn; + + public override void OnServerAddPlayer(NetworkConnection conn, AddPlayerMessage extraMessage) + { + Transform start = numPlayers == 0 ? leftRacketSpawn : rightRacketSpawn; + GameObject player = Instantiate(playerPrefab, start.position, start.rotation); + NetworkServer.AddPlayerForConnection(conn, player); + } +} diff --git a/Assets/Mirror/Examples/Pong/Scripts/NetworkManagerPong.cs.meta b/Assets/Mirror/Examples/Pong/Scripts/NetworkManagerPong.cs.meta new file mode 100644 index 000000000..4b191ea13 --- /dev/null +++ b/Assets/Mirror/Examples/Pong/Scripts/NetworkManagerPong.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 0aa3018bb284840d6a6d0acee29ab098 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: