From 2d52696d6338e0347acc124051c1d9a92074adef Mon Sep 17 00:00:00 2001 From: Bastien Humeau Date: Thu, 2 May 2024 15:07:26 -0400 Subject: [PATCH 1/7] Upgraded NGO to 1.8.1 in manifest and readme. --- Basic/Invaders/Packages/manifest.json | 2 +- Basic/Invaders/Packages/packages-lock.json | 2 +- Basic/Invaders/README.md | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/Basic/Invaders/Packages/manifest.json b/Basic/Invaders/Packages/manifest.json index fdb558c3..4dee139b 100644 --- a/Basic/Invaders/Packages/manifest.json +++ b/Basic/Invaders/Packages/manifest.json @@ -7,7 +7,7 @@ "com.unity.ide.vscode": "1.2.5", "com.unity.multiplayer.samples.coop": "https://github.com/Unity-Technologies/com.unity.multiplayer.samples.coop.git?path=/Packages/com.unity.multiplayer.samples.coop#v2.4.0", "com.unity.multiplayer.tools": "1.1.1", - "com.unity.netcode.gameobjects": "1.7.1", + "com.unity.netcode.gameobjects": "1.8.1", "com.unity.render-pipelines.universal": "14.0.11", "com.unity.textmeshpro": "3.0.6", "com.unity.timeline": "1.7.6", diff --git a/Basic/Invaders/Packages/packages-lock.json b/Basic/Invaders/Packages/packages-lock.json index 21a7e868..7485e7b0 100644 --- a/Basic/Invaders/Packages/packages-lock.json +++ b/Basic/Invaders/Packages/packages-lock.json @@ -117,7 +117,7 @@ "url": "https://packages.unity.com" }, "com.unity.netcode.gameobjects": { - "version": "1.7.1", + "version": "1.8.1", "depth": 0, "source": "registry", "dependencies": { diff --git a/Basic/Invaders/README.md b/Basic/Invaders/README.md index 7d9a8399..479af632 100644 --- a/Basic/Invaders/README.md +++ b/Basic/Invaders/README.md @@ -4,7 +4,7 @@ # Invaders [![UnityVersion](https://img.shields.io/badge/Unity%20Version:-2022.3%20LTS-57b9d3.svg?logo=unity&color=2196F3)](https://unity.com/releases/editor/whats-new/2022.3.0) -[![NetcodeVersion](https://img.shields.io/badge/Netcode%20Version:-1.7.1-57b9d3.svg?logo=unity&color=2196F3)](https://github.com/Unity-Technologies/com.unity.netcode.gameobjects/releases/tag/ngo%2F1.7.1) +[![NetcodeVersion](https://img.shields.io/badge/Netcode%20Version:-1.8.1-57b9d3.svg?logo=unity&color=2196F3)](https://github.com/Unity-Technologies/com.unity.netcode.gameobjects/releases/tag/ngo%2F1.8.1) [![LatestRelease](https://img.shields.io/badge/Latest%20%20Github%20Release:-v1.5.0-57b9d3.svg?logo=github&color=brightgreen)](https://github.com/Unity-Technologies/com.unity.multiplayer.samples.bitesize/releases/tag/v1.5.0)

From c23603ee830ed62aaec4f47b275efbd47455e434 Mon Sep 17 00:00:00 2001 From: Bastien Humeau Date: Thu, 2 May 2024 15:10:38 -0400 Subject: [PATCH 2/7] Changed ClientRpc and ServerRpc attributes to the new RpcAttribute --- Basic/Invaders/Assets/Scripts/EnemyBullet.cs | 6 +++--- Basic/Invaders/Assets/Scripts/InvadersGame.cs | 16 ++++++++-------- Basic/Invaders/Assets/Scripts/LobbyControl.cs | 14 +++++++------- Basic/Invaders/Assets/Scripts/PlayerBullet.cs | 8 ++++---- Basic/Invaders/Assets/Scripts/PlayerControl.cs | 10 ++++------ 5 files changed, 26 insertions(+), 28 deletions(-) diff --git a/Basic/Invaders/Assets/Scripts/EnemyBullet.cs b/Basic/Invaders/Assets/Scripts/EnemyBullet.cs index 67269802..5bbf2513 100644 --- a/Basic/Invaders/Assets/Scripts/EnemyBullet.cs +++ b/Basic/Invaders/Assets/Scripts/EnemyBullet.cs @@ -74,15 +74,15 @@ private void OnTriggerEnter2D(Collider2D collider) var hitShield = collider.gameObject.GetComponent(); if (hitShield != null) { - SpawnExplosionVFXClientRpc(transform.position, Quaternion.identity); + ClientSpawnExplosionVFXRpc(transform.position, Quaternion.identity); Destroy(hitShield.gameObject); NetworkObject.Despawn(); } } - [ClientRpc] - void SpawnExplosionVFXClientRpc(Vector3 spawnPosition, Quaternion spawnRotation) + [Rpc(SendTo.ClientsAndHost)] + void ClientSpawnExplosionVFXRpc(Vector3 spawnPosition, Quaternion spawnRotation) { Instantiate(m_ShieldExplosionParticle, spawnPosition, spawnRotation); } diff --git a/Basic/Invaders/Assets/Scripts/InvadersGame.cs b/Basic/Invaders/Assets/Scripts/InvadersGame.cs index 1f4113f4..9bec8131 100644 --- a/Basic/Invaders/Assets/Scripts/InvadersGame.cs +++ b/Basic/Invaders/Assets/Scripts/InvadersGame.cs @@ -198,7 +198,7 @@ private void OnClientConnected(ulong clientId) if (m_ReplicatedTimeSent) { // Send the RPC only to the newly connected client - SetReplicatedTimeRemainingClientRPC(m_TimeRemaining, new ClientRpcParams { Send = new ClientRpcSendParams { TargetClientIds = new List() { clientId } } }); + ClientSetReplicatedTimeRemainingRPC(m_TimeRemaining, RpcTarget.Single(clientId, RpcTargetUse.Temp)); } } @@ -218,7 +218,7 @@ private bool ShouldStartCountDown() //While we are counting down, continually set the replicated time remaining value for clients (client should only receive the update once) if (m_CountdownStarted.Value && !m_ReplicatedTimeSent) { - SetReplicatedTimeRemainingClientRPC(m_DelayedStartTime); + ClientSetReplicatedTimeRemainingRPC(m_DelayedStartTime, RpcTarget.ClientsAndHost); m_ReplicatedTimeSent = true; } @@ -233,9 +233,9 @@ private bool ShouldStartCountDown() /// will deal with updating it. For that, we use a ClientRPC /// /// - /// - [ClientRpc] - private void SetReplicatedTimeRemainingClientRPC(float delayedStartTime, ClientRpcParams clientRpcParams = new ClientRpcParams()) + /// + [Rpc(SendTo.SpecifiedInParams)] + private void ClientSetReplicatedTimeRemainingRPC(float delayedStartTime, RpcParams rpcParams) { // See the ShouldStartCountDown method for when the server updates the value if (m_TimeRemaining == 0) @@ -432,7 +432,7 @@ public void SetGameEnd(GameOverReason reason) if (reason != GameOverReason.Death) { this.isGameOver.Value = true; - BroadcastGameOverClientRpc(reason); // Notify our clients! + ClientBroadcastGameOverRpc(reason); // Notify our clients! return; } @@ -449,8 +449,8 @@ public void SetGameEnd(GameOverReason reason) this.isGameOver.Value = true; } - [ClientRpc] - public void BroadcastGameOverClientRpc(GameOverReason reason) + [Rpc(SendTo.ClientsAndHost)] + public void ClientBroadcastGameOverRpc(GameOverReason reason) { var localPlayerObject = NetworkManager.Singleton.LocalClient.PlayerObject; Assert.IsNotNull(localPlayerObject); diff --git a/Basic/Invaders/Assets/Scripts/LobbyControl.cs b/Basic/Invaders/Assets/Scripts/LobbyControl.cs index ebcfae2c..d3d5dd1b 100644 --- a/Basic/Invaders/Assets/Scripts/LobbyControl.cs +++ b/Basic/Invaders/Assets/Scripts/LobbyControl.cs @@ -77,7 +77,7 @@ private void UpdateAndCheckPlayersInLobby() foreach (var clientLobbyStatus in m_ClientsInLobby) { - SendClientReadyStatusUpdatesClientRpc(clientLobbyStatus.Key, clientLobbyStatus.Value); + ClientSendReadyStatusUpdatesRpc(clientLobbyStatus.Key, clientLobbyStatus.Value); if (!NetworkManager.Singleton.ConnectedClients.ContainsKey(clientLobbyStatus.Key)) //If some clients are still loading into the lobby scene then this is false @@ -124,14 +124,14 @@ private void OnClientConnectedCallback(ulong clientId) } /// - /// SendClientReadyStatusUpdatesClientRpc + /// ClientSendReadyStatusUpdatesRpc /// Sent from the server to the client when a player's status is updated. /// This also populates the connected clients' (excluding host) player state in the lobby /// /// /// - [ClientRpc] - private void SendClientReadyStatusUpdatesClientRpc(ulong clientId, bool isReady) + [Rpc(SendTo.ClientsAndHost)] + private void ClientSendReadyStatusUpdatesRpc(ulong clientId, bool isReady) { if (!IsServer) { @@ -186,7 +186,7 @@ public void PlayerIsReady() } else { - OnClientIsReadyServerRpc(NetworkManager.Singleton.LocalClientId); + ServerOnClientIsReadyRpc(NetworkManager.Singleton.LocalClientId); } GenerateUserStatsForLobby(); @@ -197,8 +197,8 @@ public void PlayerIsReady() /// Sent to the server when the player clicks the ready button /// /// clientId that is ready - [ServerRpc(RequireOwnership = false)] - private void OnClientIsReadyServerRpc(ulong clientid) + [Rpc(SendTo.Server)] + private void ServerOnClientIsReadyRpc(ulong clientid) { if (m_ClientsInLobby.ContainsKey(clientid)) { diff --git a/Basic/Invaders/Assets/Scripts/PlayerBullet.cs b/Basic/Invaders/Assets/Scripts/PlayerBullet.cs index 511fd833..a31952fe 100644 --- a/Basic/Invaders/Assets/Scripts/PlayerBullet.cs +++ b/Basic/Invaders/Assets/Scripts/PlayerBullet.cs @@ -50,7 +50,7 @@ private void OnTriggerEnter2D(Collider2D collider) // Only the server can despawn a NetworkObject hitEnemy.NetworkObject.Despawn(); - SpawnExplosionVFXClientRPC(transform.position, Quaternion.identity); + ClientSpawnExplosionVFXRPC(transform.position, Quaternion.identity); NetworkObject.Despawn(); @@ -65,10 +65,10 @@ private void OnTriggerEnter2D(Collider2D collider) } } - [ClientRpc] - void SpawnExplosionVFXClientRPC(Vector3 spawnPosition, Quaternion spawnRotation) + [Rpc(SendTo.ClientsAndHost)] + void ClientSpawnExplosionVFXRPC(Vector3 spawnPosition, Quaternion spawnRotation) { - // this instantiates at the position of the bullet, there is an offset in the Y axis on the + // this instantiates at the position of the bullet, there is an offset in the Y axis on the // particle systems in the prefab so it looks like it spawns in the middle of the enemy Instantiate(m_EnemyExplosionParticle, spawnPosition, spawnRotation); } diff --git a/Basic/Invaders/Assets/Scripts/PlayerControl.cs b/Basic/Invaders/Assets/Scripts/PlayerControl.cs index 459a907c..287dacf2 100644 --- a/Basic/Invaders/Assets/Scripts/PlayerControl.cs +++ b/Basic/Invaders/Assets/Scripts/PlayerControl.cs @@ -33,7 +33,6 @@ public class PlayerControl : NetworkBehaviour private NetworkVariable m_MoveX = new NetworkVariable(0); private GameObject m_MyBullet; - private ClientRpcParams m_OwnerRPCParams; [SerializeField] private SpriteRenderer m_PlayerVisual; @@ -114,7 +113,6 @@ public override void OnNetworkSpawn() m_Lives.OnValueChanged += OnLivesChanged; m_Score.OnValueChanged += OnScoreChanged; - if (IsServer) m_OwnerRPCParams = new ClientRpcParams { Send = new ClientRpcSendParams { TargetClientIds = new[] { OwnerClientId } } }; if (!InvadersGame.Singleton) InvadersGame.OnSingletonReady += SubscribeToDelegatesAndUpdateValues; @@ -192,7 +190,7 @@ private void InGameUpdate() if (Input.GetKeyDown(KeyCode.Space)) ShootServerRPC(); } - [ServerRpc] + [Rpc(SendTo.Server)] private void ShootServerRPC() { if (!m_IsAlive) @@ -220,7 +218,7 @@ public void HitByBullet() m_MoveX.Value = 0; m_Lives.Value = 0; InvadersGame.Singleton.SetGameEnd(GameOverReason.Death); - NotifyGameOverClientRpc(GameOverReason.Death, m_OwnerRPCParams); + ClientNotifyGameOverRpc(GameOverReason.Death);//, m_OwnerRPCParams); Instantiate(m_ExplosionParticleSystem, transform.position, quaternion.identity); // Hide graphics of this player object server-side. Note we don't want to destroy the object as it @@ -233,8 +231,8 @@ public void HitByBullet() } } - [ClientRpc] - private void NotifyGameOverClientRpc(GameOverReason reason, ClientRpcParams clientParams) + [Rpc(SendTo.Owner)] + private void ClientNotifyGameOverRpc(GameOverReason reason) { NotifyGameOver(reason); } From fde047c289f9c195d6c1987d9b6ece50b611b5fb Mon Sep 17 00:00:00 2001 From: Bastien Humeau Date: Thu, 2 May 2024 16:10:24 -0400 Subject: [PATCH 3/7] Changed OnClientConnectedCallback registration to use the new OnConnectionEvent --- Basic/Invaders/Assets/Scripts/InvadersGame.cs | 11 +++++--- Basic/Invaders/Assets/Scripts/LobbyControl.cs | 26 +++++++++++-------- 2 files changed, 22 insertions(+), 15 deletions(-) diff --git a/Basic/Invaders/Assets/Scripts/InvadersGame.cs b/Basic/Invaders/Assets/Scripts/InvadersGame.cs index 9bec8131..a0791bd2 100644 --- a/Basic/Invaders/Assets/Scripts/InvadersGame.cs +++ b/Basic/Invaders/Assets/Scripts/InvadersGame.cs @@ -148,7 +148,7 @@ public override void OnNetworkDespawn() m_Shields.Clear(); } - NetworkManager.Singleton.OnClientConnectedCallback -= OnClientConnected; + NetworkManager.Singleton.OnConnectionEvent -= OnClientConnected; } internal static event Action OnSingletonReady; @@ -187,18 +187,21 @@ public override void OnNetworkSpawn() if (IsServer) { - NetworkManager.Singleton.OnClientConnectedCallback += OnClientConnected; + NetworkManager.Singleton.OnConnectionEvent += OnClientConnected; } base.OnNetworkSpawn(); } - private void OnClientConnected(ulong clientId) + private void OnClientConnected(NetworkManager networkManager, ConnectionEventData connectionEventData) { + if (connectionEventData.EventType != ConnectionEvent.ClientConnected) + return; + if (m_ReplicatedTimeSent) { // Send the RPC only to the newly connected client - ClientSetReplicatedTimeRemainingRPC(m_TimeRemaining, RpcTarget.Single(clientId, RpcTargetUse.Temp)); + ClientSetReplicatedTimeRemainingRPC(m_TimeRemaining, RpcTarget.Single(connectionEventData.ClientId, RpcTargetUse.Temp)); } } diff --git a/Basic/Invaders/Assets/Scripts/LobbyControl.cs b/Basic/Invaders/Assets/Scripts/LobbyControl.cs index d3d5dd1b..e85aa0c1 100644 --- a/Basic/Invaders/Assets/Scripts/LobbyControl.cs +++ b/Basic/Invaders/Assets/Scripts/LobbyControl.cs @@ -34,7 +34,7 @@ public override void OnNetworkSpawn() m_AllPlayersInLobby = false; //Server will be notified when a client connects - NetworkManager.OnClientConnectedCallback += OnClientConnectedCallback; + NetworkManager.OnConnectionEvent += OnClientConnectedCallback; SceneTransitionHandler.sceneTransitionHandler.OnClientLoadedScene += ClientLoadedScene; } @@ -79,9 +79,10 @@ private void UpdateAndCheckPlayersInLobby() { ClientSendReadyStatusUpdatesRpc(clientLobbyStatus.Key, clientLobbyStatus.Value); if (!NetworkManager.Singleton.ConnectedClients.ContainsKey(clientLobbyStatus.Key)) - + { //If some clients are still loading into the lobby scene then this is false m_AllPlayersInLobby = false; + } } CheckForAllPlayersReady(); @@ -111,16 +112,19 @@ private void ClientLoadedScene(ulong clientId) /// Since we are entering a lobby and Netcode's NetworkManager is spawning the player, /// the server can be configured to only listen for connected clients at this stage. /// - /// client that connected - private void OnClientConnectedCallback(ulong clientId) + /// + /// Connection event to check for which player id is connecting. + private void OnClientConnectedCallback(NetworkManager networkManager, ConnectionEventData connectionEventData) { - if (IsServer) - { - if (!m_ClientsInLobby.ContainsKey(clientId)) m_ClientsInLobby.Add(clientId, false); - GenerateUserStatsForLobby(); + if (connectionEventData.EventType != ConnectionEvent.ClientConnected) + return; - UpdateAndCheckPlayersInLobby(); - } + var clientId = connectionEventData.ClientId; + if (!m_ClientsInLobby.ContainsKey(clientId)) + m_ClientsInLobby.Add(clientId, false); + + GenerateUserStatsForLobby(); + UpdateAndCheckPlayersInLobby(); } /// @@ -162,7 +166,7 @@ private void CheckForAllPlayersReady() if (allPlayersAreReady) { //Remove our client connected callback - NetworkManager.Singleton.OnClientConnectedCallback -= OnClientConnectedCallback; + NetworkManager.Singleton.OnConnectionEvent -= OnClientConnectedCallback; //Remove our scene loaded callback SceneTransitionHandler.sceneTransitionHandler.OnClientLoadedScene -= ClientLoadedScene; From 6ed4a492d1f31a7356912f7d473c4b507fa1bc25 Mon Sep 17 00:00:00 2001 From: Bastien Humeau Date: Thu, 2 May 2024 16:49:18 -0400 Subject: [PATCH 4/7] Changing spawn methods to use InstantiateAndSpawn --- .../Prefabs/Invaders Game Manager.prefab | 56 ++++++++------ Basic/Invaders/Assets/Prefabs/enemy1.prefab | 75 +++++++++++++----- Basic/Invaders/Assets/Prefabs/enemy2.prefab | 45 ++++++++++- Basic/Invaders/Assets/Prefabs/enemy3.prefab | 45 ++++++++++- Basic/Invaders/Assets/Prefabs/player.prefab | 74 +++++++++++++----- .../Invaders/Assets/Prefabs/superEnemy.prefab | 77 ++++++++++++++----- Basic/Invaders/Assets/Scripts/EnemyAgent.cs | 8 +- Basic/Invaders/Assets/Scripts/InvadersGame.cs | 37 +++++---- .../Invaders/Assets/Scripts/PlayerControl.cs | 10 +-- 9 files changed, 310 insertions(+), 117 deletions(-) diff --git a/Basic/Invaders/Assets/Prefabs/Invaders Game Manager.prefab b/Basic/Invaders/Assets/Prefabs/Invaders Game Manager.prefab index 3b9b380f..f09cf54f 100644 --- a/Basic/Invaders/Assets/Prefabs/Invaders Game Manager.prefab +++ b/Basic/Invaders/Assets/Prefabs/Invaders Game Manager.prefab @@ -9,8 +9,8 @@ GameObject: serializedVersion: 6 m_Component: - component: {fileID: 4266113290039088506} - - component: {fileID: 4266113290039088507} - component: {fileID: 2756959678467573149} + - component: {fileID: 4266113290039088507} m_Layer: 0 m_Name: Invaders Game Manager m_TagString: Untagged @@ -25,14 +25,35 @@ Transform: m_PrefabInstance: {fileID: 0} m_PrefabAsset: {fileID: 0} m_GameObject: {fileID: 4266113290039088508} + serializedVersion: 2 m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} m_LocalPosition: {x: 0, y: 0, z: 0} m_LocalScale: {x: 1, y: 1, z: 1} m_ConstrainProportionsScale: 0 m_Children: [] m_Father: {fileID: 0} - m_RootOrder: 0 m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} +--- !u!114 &2756959678467573149 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 4266113290039088508} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: d5a57f767e5e46a458fc5d3c628d0cbb, type: 3} + m_Name: + m_EditorClassIdentifier: + GlobalObjectIdHash: 2783302607 + InScenePlacedSourceGlobalObjectIdHash: 0 + AlwaysReplicateAsRoot: 0 + SynchronizeTransform: 1 + ActiveSceneSynchronization: 0 + SceneMigrationSynchronization: 1 + SpawnWithObservers: 1 + DontDestroyWithOwner: 0 + AutoObjectParentSync: 1 --- !u!114 &4266113290039088507 MonoBehaviour: m_ObjectHideFlags: 0 @@ -45,11 +66,16 @@ MonoBehaviour: m_Script: {fileID: 11500000, guid: d643b609c6a71c54984c1ad454faa28b, type: 3} m_Name: m_EditorClassIdentifier: - enemy1Prefab: {fileID: 100000, guid: 43ae6ad1bdadd0747811bb7a00740c2c, type: 3} - enemy2Prefab: {fileID: 100000, guid: 38a8441efb2d6d245adbf08f08705374, type: 3} - enemy3Prefab: {fileID: 100000, guid: aa50d36274d0dfc4faff2c69820b3711, type: 3} - superEnemyPrefab: {fileID: 100000, guid: e811e4fb062e31444aaf36dbec5de77c, type: 3} - shieldPrefab: {fileID: 100000, guid: b990a6e6dcf54b646a7397028fed6045, type: 3} + enemy1Prefab: {fileID: 2037077820506562951, guid: 43ae6ad1bdadd0747811bb7a00740c2c, + type: 3} + enemy2Prefab: {fileID: 1361474663871475650, guid: 38a8441efb2d6d245adbf08f08705374, + type: 3} + enemy3Prefab: {fileID: 7651551376209856180, guid: aa50d36274d0dfc4faff2c69820b3711, + type: 3} + superEnemyPrefab: {fileID: 3955316467729786863, guid: e811e4fb062e31444aaf36dbec5de77c, + type: 3} + shieldPrefab: {fileID: 6564576217164106930, guid: b990a6e6dcf54b646a7397028fed6045, + type: 3} gameTimerText: {fileID: 0} scoreText: {fileID: 0} livesText: {fileID: 0} @@ -61,19 +87,3 @@ MonoBehaviour: m_EnemyMovingDirection: m_InternalValue: 0.3 m_RandomThresholdForSaucerCreation: 0.92 ---- !u!114 &2756959678467573149 -MonoBehaviour: - m_ObjectHideFlags: 0 - m_CorrespondingSourceObject: {fileID: 0} - m_PrefabInstance: {fileID: 0} - m_PrefabAsset: {fileID: 0} - m_GameObject: {fileID: 4266113290039088508} - m_Enabled: 1 - m_EditorHideFlags: 0 - m_Script: {fileID: 11500000, guid: d5a57f767e5e46a458fc5d3c628d0cbb, type: 3} - m_Name: - m_EditorClassIdentifier: - GlobalObjectIdHash: 951099334 - AlwaysReplicateAsRoot: 0 - DontDestroyWithOwner: 0 - AutoObjectParentSync: 1 diff --git a/Basic/Invaders/Assets/Prefabs/enemy1.prefab b/Basic/Invaders/Assets/Prefabs/enemy1.prefab index b4bb95d9..29780496 100644 --- a/Basic/Invaders/Assets/Prefabs/enemy1.prefab +++ b/Basic/Invaders/Assets/Prefabs/enemy1.prefab @@ -10,11 +10,11 @@ GameObject: m_Component: - component: {fileID: 400000} - component: {fileID: 21200000} + - component: {fileID: 2037077820506562951} - component: {fileID: 11400000} - component: {fileID: 6100000} - component: {fileID: 5000000} - component: {fileID: 4223722966607089368} - - component: {fileID: 2037077820506562951} m_Layer: 0 m_Name: enemy1 m_TagString: Untagged @@ -29,13 +29,13 @@ Transform: m_PrefabInstance: {fileID: 0} m_PrefabAsset: {fileID: 0} m_GameObject: {fileID: 100000} + serializedVersion: 2 m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} m_LocalPosition: {x: -2.521718, y: 0.97297525, z: 2.9156828} m_LocalScale: {x: 1, y: 1, z: 1} m_ConstrainProportionsScale: 0 m_Children: [] m_Father: {fileID: 0} - m_RootOrder: 0 m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} --- !u!212 &21200000 SpriteRenderer: @@ -89,6 +89,27 @@ SpriteRenderer: m_WasSpriteAssigned: 1 m_MaskInteraction: 0 m_SpriteSortPoint: 0 +--- !u!114 &2037077820506562951 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 100000} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: d5a57f767e5e46a458fc5d3c628d0cbb, type: 3} + m_Name: + m_EditorClassIdentifier: + GlobalObjectIdHash: 416377817 + InScenePlacedSourceGlobalObjectIdHash: 0 + AlwaysReplicateAsRoot: 0 + SynchronizeTransform: 1 + ActiveSceneSynchronization: 0 + SceneMigrationSynchronization: 1 + SpawnWithObservers: 1 + DontDestroyWithOwner: 0 + AutoObjectParentSync: 1 --- !u!114 &11400000 MonoBehaviour: m_ObjectHideFlags: 0 @@ -102,7 +123,8 @@ MonoBehaviour: m_Name: m_EditorClassIdentifier: score: 10 - bulletPrefab: {fileID: 100000, guid: ac6ffb0923d0f7448852a32312a0263c, type: 3} + bulletPrefab: {fileID: 2336033219118315817, guid: ac6ffb0923d0f7448852a32312a0263c, + type: 3} GraceShootingPeriod: 1 --- !u!61 &6100000 BoxCollider2D: @@ -114,6 +136,25 @@ BoxCollider2D: m_Enabled: 1 m_Density: 1 m_Material: {fileID: 0} + m_IncludeLayers: + serializedVersion: 2 + m_Bits: 0 + m_ExcludeLayers: + serializedVersion: 2 + m_Bits: 0 + m_LayerOverridePriority: 0 + m_ForceSendLayers: + serializedVersion: 2 + m_Bits: 4294967295 + m_ForceReceiveLayers: + serializedVersion: 2 + m_Bits: 4294967295 + m_ContactCaptureLayers: + serializedVersion: 2 + m_Bits: 4294967295 + m_CallbackLayers: + serializedVersion: 2 + m_Bits: 4294967295 m_IsTrigger: 0 m_UsedByEffector: 0 m_UsedByComposite: 0 @@ -147,6 +188,12 @@ Rigidbody2D: m_AngularDrag: 0.05 m_GravityScale: 0 m_Material: {fileID: 0} + m_IncludeLayers: + serializedVersion: 2 + m_Bits: 0 + m_ExcludeLayers: + serializedVersion: 2 + m_Bits: 0 m_Interpolate: 0 m_SleepingMode: 1 m_CollisionDetection: 0 @@ -163,6 +210,7 @@ MonoBehaviour: m_Script: {fileID: 11500000, guid: e96cb6065543e43c4a752faaa1468eb1, type: 3} m_Name: m_EditorClassIdentifier: + UseUnreliableDeltas: 0 SyncPositionX: 1 SyncPositionY: 1 SyncPositionZ: 1 @@ -175,22 +223,9 @@ MonoBehaviour: PositionThreshold: 0 RotAngleThreshold: 0 ScaleThreshold: 0 + UseQuaternionSynchronization: 0 + UseQuaternionCompression: 0 + UseHalfFloatPrecision: 0 InLocalSpace: 0 Interpolate: 1 - CanCommitToTransform: 0 ---- !u!114 &2037077820506562951 -MonoBehaviour: - m_ObjectHideFlags: 0 - m_CorrespondingSourceObject: {fileID: 0} - m_PrefabInstance: {fileID: 0} - m_PrefabAsset: {fileID: 0} - m_GameObject: {fileID: 100000} - m_Enabled: 1 - m_EditorHideFlags: 0 - m_Script: {fileID: 11500000, guid: d5a57f767e5e46a458fc5d3c628d0cbb, type: 3} - m_Name: - m_EditorClassIdentifier: - GlobalObjectIdHash: 951099334 - AlwaysReplicateAsRoot: 0 - DontDestroyWithOwner: 0 - AutoObjectParentSync: 1 + SlerpPosition: 0 diff --git a/Basic/Invaders/Assets/Prefabs/enemy2.prefab b/Basic/Invaders/Assets/Prefabs/enemy2.prefab index e86bcfee..f6714424 100644 --- a/Basic/Invaders/Assets/Prefabs/enemy2.prefab +++ b/Basic/Invaders/Assets/Prefabs/enemy2.prefab @@ -29,12 +29,13 @@ Transform: m_PrefabInstance: {fileID: 0} m_PrefabAsset: {fileID: 0} m_GameObject: {fileID: 100000} + serializedVersion: 2 m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} m_LocalPosition: {x: -3.3369913, y: 1.6158211, z: 5.338147} m_LocalScale: {x: 1, y: 1, z: 1} + m_ConstrainProportionsScale: 0 m_Children: [] m_Father: {fileID: 0} - m_RootOrder: 0 m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} --- !u!212 &21200000 SpriteRenderer: @@ -47,6 +48,7 @@ SpriteRenderer: m_CastShadows: 0 m_ReceiveShadows: 0 m_DynamicOccludee: 1 + m_StaticShadowCaster: 0 m_MotionVectors: 1 m_LightProbeUsage: 0 m_ReflectionProbeUsage: 0 @@ -100,7 +102,8 @@ MonoBehaviour: m_Name: m_EditorClassIdentifier: score: 20 - bulletPrefab: {fileID: 100000, guid: ac6ffb0923d0f7448852a32312a0263c, type: 3} + bulletPrefab: {fileID: 2336033219118315817, guid: ac6ffb0923d0f7448852a32312a0263c, + type: 3} GraceShootingPeriod: 1 --- !u!61 &6100000 BoxCollider2D: @@ -112,6 +115,25 @@ BoxCollider2D: m_Enabled: 1 m_Density: 1 m_Material: {fileID: 0} + m_IncludeLayers: + serializedVersion: 2 + m_Bits: 0 + m_ExcludeLayers: + serializedVersion: 2 + m_Bits: 0 + m_LayerOverridePriority: 0 + m_ForceSendLayers: + serializedVersion: 2 + m_Bits: 4294967295 + m_ForceReceiveLayers: + serializedVersion: 2 + m_Bits: 4294967295 + m_ContactCaptureLayers: + serializedVersion: 2 + m_Bits: 4294967295 + m_CallbackLayers: + serializedVersion: 2 + m_Bits: 4294967295 m_IsTrigger: 0 m_UsedByEffector: 0 m_UsedByComposite: 0 @@ -145,6 +167,12 @@ Rigidbody2D: m_AngularDrag: 0.05 m_GravityScale: 0 m_Material: {fileID: 0} + m_IncludeLayers: + serializedVersion: 2 + m_Bits: 0 + m_ExcludeLayers: + serializedVersion: 2 + m_Bits: 0 m_Interpolate: 0 m_SleepingMode: 1 m_CollisionDetection: 0 @@ -161,6 +189,7 @@ MonoBehaviour: m_Script: {fileID: 11500000, guid: e96cb6065543e43c4a752faaa1468eb1, type: 3} m_Name: m_EditorClassIdentifier: + UseUnreliableDeltas: 0 SyncPositionX: 1 SyncPositionY: 1 SyncPositionZ: 1 @@ -173,9 +202,12 @@ MonoBehaviour: PositionThreshold: 0 RotAngleThreshold: 0 ScaleThreshold: 0 + UseQuaternionSynchronization: 0 + UseQuaternionCompression: 0 + UseHalfFloatPrecision: 0 InLocalSpace: 0 Interpolate: 1 - CanCommitToTransform: 0 + SlerpPosition: 0 --- !u!114 &1361474663871475650 MonoBehaviour: m_ObjectHideFlags: 0 @@ -188,7 +220,12 @@ MonoBehaviour: m_Script: {fileID: 11500000, guid: d5a57f767e5e46a458fc5d3c628d0cbb, type: 3} m_Name: m_EditorClassIdentifier: - GlobalObjectIdHash: 951099334 + GlobalObjectIdHash: 3854485402 + InScenePlacedSourceGlobalObjectIdHash: 0 AlwaysReplicateAsRoot: 0 + SynchronizeTransform: 1 + ActiveSceneSynchronization: 0 + SceneMigrationSynchronization: 1 + SpawnWithObservers: 1 DontDestroyWithOwner: 0 AutoObjectParentSync: 1 diff --git a/Basic/Invaders/Assets/Prefabs/enemy3.prefab b/Basic/Invaders/Assets/Prefabs/enemy3.prefab index f34820bb..93558f06 100644 --- a/Basic/Invaders/Assets/Prefabs/enemy3.prefab +++ b/Basic/Invaders/Assets/Prefabs/enemy3.prefab @@ -29,12 +29,13 @@ Transform: m_PrefabInstance: {fileID: 0} m_PrefabAsset: {fileID: 0} m_GameObject: {fileID: 100000} + serializedVersion: 2 m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} m_LocalPosition: {x: -2.877448, y: 1.0368326, z: 3.9234695} m_LocalScale: {x: 1, y: 1, z: 1} + m_ConstrainProportionsScale: 0 m_Children: [] m_Father: {fileID: 0} - m_RootOrder: 0 m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} --- !u!212 &21200000 SpriteRenderer: @@ -47,6 +48,7 @@ SpriteRenderer: m_CastShadows: 0 m_ReceiveShadows: 0 m_DynamicOccludee: 1 + m_StaticShadowCaster: 0 m_MotionVectors: 1 m_LightProbeUsage: 0 m_ReflectionProbeUsage: 0 @@ -100,7 +102,8 @@ MonoBehaviour: m_Name: m_EditorClassIdentifier: score: 30 - bulletPrefab: {fileID: 100000, guid: ac6ffb0923d0f7448852a32312a0263c, type: 3} + bulletPrefab: {fileID: 2336033219118315817, guid: ac6ffb0923d0f7448852a32312a0263c, + type: 3} GraceShootingPeriod: 1 --- !u!61 &6100000 BoxCollider2D: @@ -112,6 +115,25 @@ BoxCollider2D: m_Enabled: 1 m_Density: 1 m_Material: {fileID: 0} + m_IncludeLayers: + serializedVersion: 2 + m_Bits: 0 + m_ExcludeLayers: + serializedVersion: 2 + m_Bits: 0 + m_LayerOverridePriority: 0 + m_ForceSendLayers: + serializedVersion: 2 + m_Bits: 4294967295 + m_ForceReceiveLayers: + serializedVersion: 2 + m_Bits: 4294967295 + m_ContactCaptureLayers: + serializedVersion: 2 + m_Bits: 4294967295 + m_CallbackLayers: + serializedVersion: 2 + m_Bits: 4294967295 m_IsTrigger: 0 m_UsedByEffector: 0 m_UsedByComposite: 0 @@ -145,6 +167,12 @@ Rigidbody2D: m_AngularDrag: 0.05 m_GravityScale: 0 m_Material: {fileID: 0} + m_IncludeLayers: + serializedVersion: 2 + m_Bits: 0 + m_ExcludeLayers: + serializedVersion: 2 + m_Bits: 0 m_Interpolate: 0 m_SleepingMode: 1 m_CollisionDetection: 0 @@ -161,6 +189,7 @@ MonoBehaviour: m_Script: {fileID: 11500000, guid: e96cb6065543e43c4a752faaa1468eb1, type: 3} m_Name: m_EditorClassIdentifier: + UseUnreliableDeltas: 0 SyncPositionX: 1 SyncPositionY: 1 SyncPositionZ: 1 @@ -173,9 +202,12 @@ MonoBehaviour: PositionThreshold: 0.001 RotAngleThreshold: 0.01 ScaleThreshold: 0.01 + UseQuaternionSynchronization: 0 + UseQuaternionCompression: 0 + UseHalfFloatPrecision: 0 InLocalSpace: 0 Interpolate: 1 - CanCommitToTransform: 0 + SlerpPosition: 0 --- !u!114 &7651551376209856180 MonoBehaviour: m_ObjectHideFlags: 0 @@ -188,7 +220,12 @@ MonoBehaviour: m_Script: {fileID: 11500000, guid: d5a57f767e5e46a458fc5d3c628d0cbb, type: 3} m_Name: m_EditorClassIdentifier: - GlobalObjectIdHash: 951099334 + GlobalObjectIdHash: 3432298371 + InScenePlacedSourceGlobalObjectIdHash: 0 AlwaysReplicateAsRoot: 0 + SynchronizeTransform: 1 + ActiveSceneSynchronization: 0 + SceneMigrationSynchronization: 1 + SpawnWithObservers: 1 DontDestroyWithOwner: 0 AutoObjectParentSync: 1 diff --git a/Basic/Invaders/Assets/Prefabs/player.prefab b/Basic/Invaders/Assets/Prefabs/player.prefab index 9aa0d647..138398fd 100644 --- a/Basic/Invaders/Assets/Prefabs/player.prefab +++ b/Basic/Invaders/Assets/Prefabs/player.prefab @@ -10,10 +10,10 @@ GameObject: m_Component: - component: {fileID: 400000} - component: {fileID: 21200000} + - component: {fileID: 5053919295125167455} - component: {fileID: 11400000} - component: {fileID: 6100000} - component: {fileID: 5000000} - - component: {fileID: 5053919295125167455} - component: {fileID: 2800302518702725854} m_Layer: 0 m_Name: player @@ -29,13 +29,13 @@ Transform: m_PrefabInstance: {fileID: 0} m_PrefabAsset: {fileID: 0} m_GameObject: {fileID: 100000} + serializedVersion: 2 m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} m_LocalPosition: {x: -3.2296677, y: 1.0967851, z: 6.24889} m_LocalScale: {x: 1, y: 1, z: 1} m_ConstrainProportionsScale: 0 m_Children: [] m_Father: {fileID: 0} - m_RootOrder: 0 m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} --- !u!212 &21200000 SpriteRenderer: @@ -89,6 +89,27 @@ SpriteRenderer: m_WasSpriteAssigned: 1 m_MaskInteraction: 0 m_SpriteSortPoint: 0 +--- !u!114 &5053919295125167455 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 100000} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: d5a57f767e5e46a458fc5d3c628d0cbb, type: 3} + m_Name: + m_EditorClassIdentifier: + GlobalObjectIdHash: 915374853 + InScenePlacedSourceGlobalObjectIdHash: 0 + AlwaysReplicateAsRoot: 0 + SynchronizeTransform: 1 + ActiveSceneSynchronization: 0 + SceneMigrationSynchronization: 1 + SpawnWithObservers: 1 + DontDestroyWithOwner: 0 + AutoObjectParentSync: 1 --- !u!114 &11400000 MonoBehaviour: m_ObjectHideFlags: 0 @@ -101,7 +122,8 @@ MonoBehaviour: m_Script: {fileID: 11500000, guid: 74fc8e136514c41458e083092b30afed, type: 3} m_Name: m_EditorClassIdentifier: - bulletPrefab: {fileID: 100000, guid: 6dfb311828493c3409e0f7973872052e, type: 3} + bulletPrefab: {fileID: 2859882261451710602, guid: 6dfb311828493c3409e0f7973872052e, + type: 3} m_MoveSpeed: 4.5 m_Lives: m_InternalValue: 3 @@ -121,6 +143,25 @@ BoxCollider2D: m_Enabled: 1 m_Density: 1 m_Material: {fileID: 0} + m_IncludeLayers: + serializedVersion: 2 + m_Bits: 0 + m_ExcludeLayers: + serializedVersion: 2 + m_Bits: 0 + m_LayerOverridePriority: 0 + m_ForceSendLayers: + serializedVersion: 2 + m_Bits: 4294967295 + m_ForceReceiveLayers: + serializedVersion: 2 + m_Bits: 4294967295 + m_ContactCaptureLayers: + serializedVersion: 2 + m_Bits: 4294967295 + m_CallbackLayers: + serializedVersion: 2 + m_Bits: 4294967295 m_IsTrigger: 1 m_UsedByEffector: 0 m_UsedByComposite: 0 @@ -154,26 +195,16 @@ Rigidbody2D: m_AngularDrag: 0.05 m_GravityScale: 0 m_Material: {fileID: 0} + m_IncludeLayers: + serializedVersion: 2 + m_Bits: 0 + m_ExcludeLayers: + serializedVersion: 2 + m_Bits: 0 m_Interpolate: 0 m_SleepingMode: 1 m_CollisionDetection: 0 m_Constraints: 0 ---- !u!114 &5053919295125167455 -MonoBehaviour: - m_ObjectHideFlags: 0 - m_CorrespondingSourceObject: {fileID: 0} - m_PrefabInstance: {fileID: 0} - m_PrefabAsset: {fileID: 0} - m_GameObject: {fileID: 100000} - m_Enabled: 1 - m_EditorHideFlags: 0 - m_Script: {fileID: 11500000, guid: d5a57f767e5e46a458fc5d3c628d0cbb, type: 3} - m_Name: - m_EditorClassIdentifier: - GlobalObjectIdHash: 951099334 - AlwaysReplicateAsRoot: 0 - DontDestroyWithOwner: 0 - AutoObjectParentSync: 1 --- !u!114 &2800302518702725854 MonoBehaviour: m_ObjectHideFlags: 0 @@ -186,6 +217,7 @@ MonoBehaviour: m_Script: {fileID: 11500000, guid: df2868252ab5c4d1da357e8f11f1b524, type: 3} m_Name: m_EditorClassIdentifier: + UseUnreliableDeltas: 0 SyncPositionX: 1 SyncPositionY: 0 SyncPositionZ: 0 @@ -198,5 +230,9 @@ MonoBehaviour: PositionThreshold: 0.001 RotAngleThreshold: 0.01 ScaleThreshold: 0.01 + UseQuaternionSynchronization: 0 + UseQuaternionCompression: 0 + UseHalfFloatPrecision: 0 InLocalSpace: 0 Interpolate: 1 + SlerpPosition: 0 diff --git a/Basic/Invaders/Assets/Prefabs/superEnemy.prefab b/Basic/Invaders/Assets/Prefabs/superEnemy.prefab index 8988a409..60c4eaff 100644 --- a/Basic/Invaders/Assets/Prefabs/superEnemy.prefab +++ b/Basic/Invaders/Assets/Prefabs/superEnemy.prefab @@ -11,11 +11,11 @@ GameObject: - component: {fileID: 400000} - component: {fileID: 21200000} - component: {fileID: 5000000} + - component: {fileID: 3955316467729786863} - component: {fileID: 11400006} - component: {fileID: 11400004} - component: {fileID: 6100000} - component: {fileID: 8984612552865464625} - - component: {fileID: 3955316467729786863} m_Layer: 0 m_Name: superEnemy m_TagString: Untagged @@ -30,12 +30,13 @@ Transform: m_PrefabInstance: {fileID: 0} m_PrefabAsset: {fileID: 0} m_GameObject: {fileID: 100000} + serializedVersion: 2 m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} m_LocalPosition: {x: 1.2698746, y: 0.8354411, z: -1.6262951} m_LocalScale: {x: 1, y: 1, z: 1} + m_ConstrainProportionsScale: 0 m_Children: [] m_Father: {fileID: 0} - m_RootOrder: 0 m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} --- !u!212 &21200000 SpriteRenderer: @@ -48,6 +49,7 @@ SpriteRenderer: m_CastShadows: 0 m_ReceiveShadows: 0 m_DynamicOccludee: 1 + m_StaticShadowCaster: 0 m_MotionVectors: 1 m_LightProbeUsage: 0 m_ReflectionProbeUsage: 0 @@ -105,10 +107,37 @@ Rigidbody2D: m_AngularDrag: 0.05 m_GravityScale: 0 m_Material: {fileID: 0} + m_IncludeLayers: + serializedVersion: 2 + m_Bits: 0 + m_ExcludeLayers: + serializedVersion: 2 + m_Bits: 0 m_Interpolate: 0 m_SleepingMode: 1 m_CollisionDetection: 0 m_Constraints: 0 +--- !u!114 &3955316467729786863 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 100000} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: d5a57f767e5e46a458fc5d3c628d0cbb, type: 3} + m_Name: + m_EditorClassIdentifier: + GlobalObjectIdHash: 1887726101 + InScenePlacedSourceGlobalObjectIdHash: 0 + AlwaysReplicateAsRoot: 0 + SynchronizeTransform: 1 + ActiveSceneSynchronization: 0 + SceneMigrationSynchronization: 1 + SpawnWithObservers: 1 + DontDestroyWithOwner: 0 + AutoObjectParentSync: 1 --- !u!114 &11400006 MonoBehaviour: m_ObjectHideFlags: 0 @@ -122,7 +151,8 @@ MonoBehaviour: m_Name: m_EditorClassIdentifier: score: 75 - bulletPrefab: {fileID: 100000, guid: ac6ffb0923d0f7448852a32312a0263c, type: 3} + bulletPrefab: {fileID: 2336033219118315817, guid: ac6ffb0923d0f7448852a32312a0263c, + type: 3} GraceShootingPeriod: 1 --- !u!114 &11400004 MonoBehaviour: @@ -147,6 +177,25 @@ BoxCollider2D: m_Enabled: 1 m_Density: 1 m_Material: {fileID: 0} + m_IncludeLayers: + serializedVersion: 2 + m_Bits: 0 + m_ExcludeLayers: + serializedVersion: 2 + m_Bits: 0 + m_LayerOverridePriority: 0 + m_ForceSendLayers: + serializedVersion: 2 + m_Bits: 4294967295 + m_ForceReceiveLayers: + serializedVersion: 2 + m_Bits: 4294967295 + m_ContactCaptureLayers: + serializedVersion: 2 + m_Bits: 4294967295 + m_CallbackLayers: + serializedVersion: 2 + m_Bits: 4294967295 m_IsTrigger: 0 m_UsedByEffector: 0 m_UsedByComposite: 0 @@ -175,6 +224,7 @@ MonoBehaviour: m_Script: {fileID: 11500000, guid: e96cb6065543e43c4a752faaa1468eb1, type: 3} m_Name: m_EditorClassIdentifier: + UseUnreliableDeltas: 0 SyncPositionX: 1 SyncPositionY: 1 SyncPositionZ: 1 @@ -187,22 +237,9 @@ MonoBehaviour: PositionThreshold: 0.001 RotAngleThreshold: 0.01 ScaleThreshold: 0.01 + UseQuaternionSynchronization: 0 + UseQuaternionCompression: 0 + UseHalfFloatPrecision: 0 InLocalSpace: 0 Interpolate: 1 - CanCommitToTransform: 0 ---- !u!114 &3955316467729786863 -MonoBehaviour: - m_ObjectHideFlags: 0 - m_CorrespondingSourceObject: {fileID: 0} - m_PrefabInstance: {fileID: 0} - m_PrefabAsset: {fileID: 0} - m_GameObject: {fileID: 100000} - m_Enabled: 1 - m_EditorHideFlags: 0 - m_Script: {fileID: 11500000, guid: d5a57f767e5e46a458fc5d3c628d0cbb, type: 3} - m_Name: - m_EditorClassIdentifier: - GlobalObjectIdHash: 951099334 - AlwaysReplicateAsRoot: 0 - DontDestroyWithOwner: 0 - AutoObjectParentSync: 1 + SlerpPosition: 0 diff --git a/Basic/Invaders/Assets/Scripts/EnemyAgent.cs b/Basic/Invaders/Assets/Scripts/EnemyAgent.cs index 2cb398f5..2993ba95 100644 --- a/Basic/Invaders/Assets/Scripts/EnemyAgent.cs +++ b/Basic/Invaders/Assets/Scripts/EnemyAgent.cs @@ -1,4 +1,5 @@ using System; +using Unity.Mathematics; using Unity.Netcode; using UnityEngine; using UnityEngine.Assertions; @@ -10,7 +11,7 @@ public class EnemyAgent : NetworkBehaviour private const float k_ShootTimer = 1.25f; [Header("Enemy Settings")] public int score = 50; - public GameObject bulletPrefab; + public NetworkObject bulletPrefab; public float GraceShootingPeriod = 1.0f; // A period of time in which the enemy will not shoot at the start public bool canShoot { get; set; } @@ -80,8 +81,9 @@ private void Update() private void SpawnBullet() { - var myBullet = Instantiate(bulletPrefab, transform.position - Vector3.up, Quaternion.identity); - myBullet.GetComponent().Spawn(); + bulletPrefab.InstantiateAndSpawn(NetworkManager.Singleton, + position: transform.position - Vector3.up, + rotation: quaternion.identity); } private void OnTriggerEnter2D(Collider2D collider) diff --git a/Basic/Invaders/Assets/Scripts/InvadersGame.cs b/Basic/Invaders/Assets/Scripts/InvadersGame.cs index a0791bd2..fdaf7d32 100644 --- a/Basic/Invaders/Assets/Scripts/InvadersGame.cs +++ b/Basic/Invaders/Assets/Scripts/InvadersGame.cs @@ -39,11 +39,11 @@ public class InvadersGame : NetworkBehaviour private const float k_BottomBoundaryOffset = 1.25f; [Header("Prefab settings")] - public GameObject enemy1Prefab; - public GameObject enemy2Prefab; - public GameObject enemy3Prefab; - public GameObject superEnemyPrefab; - public GameObject shieldPrefab; + public NetworkObject enemy1Prefab; + public NetworkObject enemy2Prefab; + public NetworkObject enemy3Prefab; + public NetworkObject superEnemyPrefab; + public NetworkObject shieldPrefab; [Header("UI Settings")] public TMP_Text gameTimerText; @@ -82,7 +82,7 @@ public class InvadersGame : NetworkBehaviour // the timer should only be synced at the beginning // and then let the client update it in a predictive manner private bool m_ReplicatedTimeSent = false; - private GameObject m_Saucer; + private NetworkObject m_Saucer; private List m_Shields = new List(); private float m_TimeRemaining; @@ -531,7 +531,7 @@ public void ExitGame() SceneTransitionHandler.sceneTransitionHandler.ExitAndLoadStartMenu(); } - private void CreateShield(GameObject prefab, int posX, int posY) + private void CreateShield(NetworkObject prefab, int posX, int posY) { Assert.IsTrue(IsServer, "Create Shield should be called server-side only!"); @@ -550,10 +550,10 @@ private void CreateShield(GameObject prefab, int posX, int posY) continue; } - var shield = Instantiate(prefab, new Vector3(x - 1, y, 0), Quaternion.identity); - // Spawn the Networked Object, this should notify the clients - shield.GetComponent().Spawn(); + prefab.InstantiateAndSpawn(NetworkManager.Singleton, + position: new Vector3(x - 1, y, 0), + rotation: Quaternion.identity); xcount += 1; } @@ -573,22 +573,21 @@ private void CreateSuperEnemy() { Assert.IsTrue(IsServer, "Create Saucer should be called server-side only!"); - m_Saucer = Instantiate(superEnemyPrefab, saucerSpawnPoint.position, Quaternion.identity); - // Spawn the Networked Object, this should notify the clients - m_Saucer.GetComponent().Spawn(); + m_Saucer = superEnemyPrefab.InstantiateAndSpawn(NetworkManager.Singleton, + position: saucerSpawnPoint.position, + rotation: Quaternion.identity); } - private void CreateEnemy(GameObject prefab, float posX, float posY) + private void CreateEnemy(NetworkObject prefab, float posX, float posY) { Assert.IsTrue(IsServer, "Create Enemy should be called server-side only!"); - var enemy = Instantiate(prefab); - enemy.transform.position = new Vector3(posX, posY, 0.0f); - enemy.GetComponent().Setup(Mathf.RoundToInt(posX), Mathf.RoundToInt(posY)); - // Spawn the Networked Object, this should notify the clients - enemy.GetComponent().Spawn(); + var enemy = prefab.InstantiateAndSpawn(NetworkManager.Singleton, + position: new Vector3(posX, posY, 0.0f), + rotation: Quaternion.identity); + enemy.GetComponent().Setup(Mathf.RoundToInt(posX), Mathf.RoundToInt(posY)); } public void CreateEnemies() diff --git a/Basic/Invaders/Assets/Scripts/PlayerControl.cs b/Basic/Invaders/Assets/Scripts/PlayerControl.cs index 287dacf2..39f875f0 100644 --- a/Basic/Invaders/Assets/Scripts/PlayerControl.cs +++ b/Basic/Invaders/Assets/Scripts/PlayerControl.cs @@ -3,12 +3,11 @@ using Unity.Netcode; using UnityEngine; using UnityEngine.Assertions; -using UnityEngine.Rendering.VirtualTexturing; public class PlayerControl : NetworkBehaviour { [Header("Weapon Settings")] - public GameObject bulletPrefab; + public NetworkObject bulletPrefab; [Header("Movement Settings")] [SerializeField] @@ -32,7 +31,7 @@ public class PlayerControl : NetworkBehaviour private NetworkVariable m_MoveX = new NetworkVariable(0); - private GameObject m_MyBullet; + private NetworkObject m_MyBullet; [SerializeField] private SpriteRenderer m_PlayerVisual; @@ -198,9 +197,10 @@ private void ShootServerRPC() if (m_MyBullet == null) { - m_MyBullet = Instantiate(bulletPrefab, transform.position + Vector3.up, Quaternion.identity); + m_MyBullet = bulletPrefab.InstantiateAndSpawn(NetworkManager.Singleton, + position: transform.position + Vector3.up, + rotation: Quaternion.identity); m_MyBullet.GetComponent().owner = this; - m_MyBullet.GetComponent().Spawn(); } } From ac62665febabdd5e25ba3547e47656a6122f55d8 Mon Sep 17 00:00:00 2001 From: Bastien Humeau Date: Mon, 6 May 2024 14:28:02 -0400 Subject: [PATCH 5/7] Added changelog entry. --- CHANGELOG.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index cb34a925..a72a783d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -39,6 +39,10 @@ #### Changed - Upgraded to IDE Rider v3.0.28 (#166) - Upgraded to Unity 2022.3.27f1 (#169) +- Upgraded to Netcode for GameObjects v1.8.1 (#172) + - Upgraded to the newer API for Rpcs, Universal Rpcs + - Upgraded to the newer API for NetworkObject spawning to use NetworkObject.InstantiateAndSpawn + - Upgraded usage of NetworkManager.OnClientConnectedCallback to the new NetworkManager.OnConnectionEvent ## [1.5.0] 2023-12-15 From 1c9ea1e1ae778888ca06e8ca6f63a7a2e455e583 Mon Sep 17 00:00:00 2001 From: Bastien Humeau Date: Mon, 13 May 2024 16:41:56 -0400 Subject: [PATCH 6/7] Renamed Rpc methods properly. --- Basic/Invaders/Assets/Scripts/InvadersGame.cs | 6 +++--- Basic/Invaders/Assets/Scripts/PlayerBullet.cs | 4 ++-- Basic/Invaders/Assets/Scripts/PlayerControl.cs | 4 ++-- 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/Basic/Invaders/Assets/Scripts/InvadersGame.cs b/Basic/Invaders/Assets/Scripts/InvadersGame.cs index fdaf7d32..be8cc272 100644 --- a/Basic/Invaders/Assets/Scripts/InvadersGame.cs +++ b/Basic/Invaders/Assets/Scripts/InvadersGame.cs @@ -201,7 +201,7 @@ private void OnClientConnected(NetworkManager networkManager, ConnectionEventDat if (m_ReplicatedTimeSent) { // Send the RPC only to the newly connected client - ClientSetReplicatedTimeRemainingRPC(m_TimeRemaining, RpcTarget.Single(connectionEventData.ClientId, RpcTargetUse.Temp)); + ClientSetReplicatedTimeRemainingRpc(m_TimeRemaining, RpcTarget.Single(connectionEventData.ClientId, RpcTargetUse.Temp)); } } @@ -221,7 +221,7 @@ private bool ShouldStartCountDown() //While we are counting down, continually set the replicated time remaining value for clients (client should only receive the update once) if (m_CountdownStarted.Value && !m_ReplicatedTimeSent) { - ClientSetReplicatedTimeRemainingRPC(m_DelayedStartTime, RpcTarget.ClientsAndHost); + ClientSetReplicatedTimeRemainingRpc(m_DelayedStartTime, RpcTarget.ClientsAndHost); m_ReplicatedTimeSent = true; } @@ -238,7 +238,7 @@ private bool ShouldStartCountDown() /// /// [Rpc(SendTo.SpecifiedInParams)] - private void ClientSetReplicatedTimeRemainingRPC(float delayedStartTime, RpcParams rpcParams) + private void ClientSetReplicatedTimeRemainingRpc(float delayedStartTime, RpcParams rpcParams) { // See the ShouldStartCountDown method for when the server updates the value if (m_TimeRemaining == 0) diff --git a/Basic/Invaders/Assets/Scripts/PlayerBullet.cs b/Basic/Invaders/Assets/Scripts/PlayerBullet.cs index a31952fe..d6a3d4c4 100644 --- a/Basic/Invaders/Assets/Scripts/PlayerBullet.cs +++ b/Basic/Invaders/Assets/Scripts/PlayerBullet.cs @@ -50,7 +50,7 @@ private void OnTriggerEnter2D(Collider2D collider) // Only the server can despawn a NetworkObject hitEnemy.NetworkObject.Despawn(); - ClientSpawnExplosionVFXRPC(transform.position, Quaternion.identity); + ClientSpawnExplosionVFXRpc(transform.position, Quaternion.identity); NetworkObject.Despawn(); @@ -66,7 +66,7 @@ private void OnTriggerEnter2D(Collider2D collider) } [Rpc(SendTo.ClientsAndHost)] - void ClientSpawnExplosionVFXRPC(Vector3 spawnPosition, Quaternion spawnRotation) + void ClientSpawnExplosionVFXRpc(Vector3 spawnPosition, Quaternion spawnRotation) { // this instantiates at the position of the bullet, there is an offset in the Y axis on the // particle systems in the prefab so it looks like it spawns in the middle of the enemy diff --git a/Basic/Invaders/Assets/Scripts/PlayerControl.cs b/Basic/Invaders/Assets/Scripts/PlayerControl.cs index 39f875f0..80d4fd93 100644 --- a/Basic/Invaders/Assets/Scripts/PlayerControl.cs +++ b/Basic/Invaders/Assets/Scripts/PlayerControl.cs @@ -186,11 +186,11 @@ private void InGameUpdate() transform.position + newMovement, m_MoveSpeed * Time.deltaTime); } - if (Input.GetKeyDown(KeyCode.Space)) ShootServerRPC(); + if (Input.GetKeyDown(KeyCode.Space)) ServerShootRpc(); } [Rpc(SendTo.Server)] - private void ShootServerRPC() + private void ServerShootRpc() { if (!m_IsAlive) return; From 696a1bd100ab03a00300142d21a4587b35b7b625 Mon Sep 17 00:00:00 2001 From: Bastien Humeau Date: Fri, 17 May 2024 13:52:38 -0400 Subject: [PATCH 7/7] ConnectionEvent renaming to make it clear it is executed only on the server side --- Basic/Invaders/Assets/Scripts/InvadersGame.cs | 8 ++++---- Basic/Invaders/Assets/Scripts/LobbyControl.cs | 6 +++--- Basic/Invaders/Assets/Scripts/PlayerControl.cs | 2 +- 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/Basic/Invaders/Assets/Scripts/InvadersGame.cs b/Basic/Invaders/Assets/Scripts/InvadersGame.cs index be8cc272..c94635e5 100644 --- a/Basic/Invaders/Assets/Scripts/InvadersGame.cs +++ b/Basic/Invaders/Assets/Scripts/InvadersGame.cs @@ -146,9 +146,9 @@ public override void OnNetworkDespawn() { m_Enemies.Clear(); m_Shields.Clear(); - } - NetworkManager.Singleton.OnConnectionEvent -= OnClientConnected; + NetworkManager.Singleton.OnConnectionEvent -= ServerOnConnectionEvent; + } } internal static event Action OnSingletonReady; @@ -187,13 +187,13 @@ public override void OnNetworkSpawn() if (IsServer) { - NetworkManager.Singleton.OnConnectionEvent += OnClientConnected; + NetworkManager.Singleton.OnConnectionEvent += ServerOnConnectionEvent; } base.OnNetworkSpawn(); } - private void OnClientConnected(NetworkManager networkManager, ConnectionEventData connectionEventData) + private void ServerOnConnectionEvent(NetworkManager networkManager, ConnectionEventData connectionEventData) { if (connectionEventData.EventType != ConnectionEvent.ClientConnected) return; diff --git a/Basic/Invaders/Assets/Scripts/LobbyControl.cs b/Basic/Invaders/Assets/Scripts/LobbyControl.cs index e85aa0c1..59b20137 100644 --- a/Basic/Invaders/Assets/Scripts/LobbyControl.cs +++ b/Basic/Invaders/Assets/Scripts/LobbyControl.cs @@ -34,7 +34,7 @@ public override void OnNetworkSpawn() m_AllPlayersInLobby = false; //Server will be notified when a client connects - NetworkManager.OnConnectionEvent += OnClientConnectedCallback; + NetworkManager.Singleton.OnConnectionEvent += ServerOnConnectionEvent; SceneTransitionHandler.sceneTransitionHandler.OnClientLoadedScene += ClientLoadedScene; } @@ -114,7 +114,7 @@ private void ClientLoadedScene(ulong clientId) /// /// /// Connection event to check for which player id is connecting. - private void OnClientConnectedCallback(NetworkManager networkManager, ConnectionEventData connectionEventData) + private void ServerOnConnectionEvent(NetworkManager networkManager, ConnectionEventData connectionEventData) { if (connectionEventData.EventType != ConnectionEvent.ClientConnected) return; @@ -166,7 +166,7 @@ private void CheckForAllPlayersReady() if (allPlayersAreReady) { //Remove our client connected callback - NetworkManager.Singleton.OnConnectionEvent -= OnClientConnectedCallback; + NetworkManager.Singleton.OnConnectionEvent -= ServerOnConnectionEvent; //Remove our scene loaded callback SceneTransitionHandler.sceneTransitionHandler.OnClientLoadedScene -= ClientLoadedScene; diff --git a/Basic/Invaders/Assets/Scripts/PlayerControl.cs b/Basic/Invaders/Assets/Scripts/PlayerControl.cs index 80d4fd93..7f60460c 100644 --- a/Basic/Invaders/Assets/Scripts/PlayerControl.cs +++ b/Basic/Invaders/Assets/Scripts/PlayerControl.cs @@ -218,7 +218,7 @@ public void HitByBullet() m_MoveX.Value = 0; m_Lives.Value = 0; InvadersGame.Singleton.SetGameEnd(GameOverReason.Death); - ClientNotifyGameOverRpc(GameOverReason.Death);//, m_OwnerRPCParams); + ClientNotifyGameOverRpc(GameOverReason.Death); Instantiate(m_ExplosionParticleSystem, transform.position, quaternion.identity); // Hide graphics of this player object server-side. Note we don't want to destroy the object as it