Skip to content

Commit

Permalink
fix: ClientNetworkTransform fix with 1.0.1+ changes main (#726)
Browse files Browse the repository at this point in the history
* Removing RPC based update and bumping package dependency

* Adding changelog

* bumping versions

* missing package lock since 1.0.2 wasn't out yet

* changelog update

* quick fix for behaviour index out of bound issue
  • Loading branch information
SamuelBellomo authored Sep 15, 2022
1 parent 6ef055b commit 554bbeb
Show file tree
Hide file tree
Showing 7 changed files with 19 additions and 40 deletions.
2 changes: 1 addition & 1 deletion Assets/Scripts/Gameplay/Input/ClientClickFeedback.cs
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ void Start()
{
if (NetworkManager.Singleton.LocalClientId != OwnerClientId)
{
Destroy(this);
enabled = false;
return;
}

Expand Down
2 changes: 1 addition & 1 deletion Assets/Scripts/Utils/NetworkOverlay/NetworkStats.cs
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ public override void OnNetworkSpawn()
bool isClientOnly = IsClient && !IsServer;
if (!IsOwner && isClientOnly) // we don't want to track player ghost stats, only our own
{
Destroy(this);
enabled = false;
return;
}

Expand Down
5 changes: 5 additions & 0 deletions Packages/com.unity.multiplayer.samples.coop/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
# Multiplayer Samples Co-op Changelog

## [1.3.1-pre] - 2022-09-13

### Fixed
* Updating ClientNetworkTransform for latest NGO 1.0.1+ (#726) This fixes the new behaviour where both RPCs and netvars were sending the same data. Now CNT is netvar based only, making it send on tick just like NetworkTransform and other network variables would.

## [1.3.0-pre] - 2022-06-23

### Added
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,8 @@
using Unity.Netcode.Components;
using Unity.Netcode;
using UnityEngine;

namespace Unity.Multiplayer.Samples.Utilities.ClientAuthority
{
// TODO inherit from `NetworkBehaviour` instead of `NetworkTransform` to cut direct relationship between two
// TODO change to owner netvar instead of RPC based
/// <summary>
/// Used for syncing a transform with client side changes. This includes host. Pure server as owner isn't supported by this. Please use NetworkTransform
/// for transforms that'll always be owned by the server.
Expand All @@ -15,31 +12,8 @@ public class ClientNetworkTransform : NetworkTransform
{
/// <summary>
/// Used to determine who can write to this transform. Owner client only.
/// Changing this value alone will not allow you to create a NetworkTransform which can be written to by clients.
/// We're using RPCs to send updated values from client to server. Netcode doesn't support client side network variable writing.
/// This imposes state to the server. This is putting trust on your clients. Make sure no security-sensitive features use this transform.
/// </summary>
// This is public to make sure that users don't depend on this IsClient && IsOwner check in their code. If this logic changes in the future, we can make it invisible here

public override void OnNetworkSpawn()
{
base.OnNetworkSpawn();
CanCommitToTransform = IsOwner;
}

protected override void Update()
{
CanCommitToTransform = IsOwner;
base.Update();
if (NetworkManager.Singleton != null && (NetworkManager.Singleton.IsConnectedClient || NetworkManager.Singleton.IsListening))
{
if (CanCommitToTransform)
{
TryCommitTransformToServer(transform, NetworkManager.LocalTime.Time);
}
}
}

protected override bool OnIsServerAuthoritative()
{
return false;
Expand Down
8 changes: 4 additions & 4 deletions Packages/com.unity.multiplayer.samples.coop/package.json
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
{
"name": "com.unity.multiplayer.samples.coop",
"displayName": "Multiplayer Samples Utilities",
"version": "1.3.0-pre",
"version": "1.3.1",
"type": "template",
"host": "hub",
"unity": "2020.3",
"description": "Utilities package built on top of Netcode for GameObjects, providing useful scripts and tools.",
"dependencies": {
"com.unity.learn.iet-framework": "1.2.1",
"com.unity.multiplayer.tools": "1.0.0-pre.7",
"com.unity.netcode.gameobjects": "1.0.0-pre.10",
"com.unity.multiplayer.tools": "1.0.0",
"com.unity.netcode.gameobjects": "1.0.2",
"com.unity.services.authentication": "1.0.0-pre.4",
"com.unity.services.lobby": "1.0.0-pre.6",
"com.unity.services.relay": "1.0.2"
}
}
}
4 changes: 2 additions & 2 deletions Packages/manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@
"com.unity.ide.vscode": "1.2.5",
"com.unity.learn.iet-framework": "2.2.1",
"com.unity.memoryprofiler": "0.5.0-preview.1",
"com.unity.netcode.gameobjects": "1.0.0-pre.10",
"com.unity.multiplayer.tools": "1.0.0-pre.7",
"com.unity.netcode.gameobjects": "1.0.2",
"com.unity.multiplayer.tools": "1.0.0",
"com.unity.postprocessing": "3.2.1",
"com.unity.render-pipelines.universal": "12.1.6",
"com.unity.services.authentication": "1.0.0-pre.4",
Expand Down
12 changes: 6 additions & 6 deletions Packages/packages-lock.json
Original file line number Diff line number Diff line change
Expand Up @@ -121,15 +121,15 @@
"source": "embedded",
"dependencies": {
"com.unity.learn.iet-framework": "1.2.1",
"com.unity.multiplayer.tools": "1.0.0-pre.7",
"com.unity.netcode.gameobjects": "1.0.0-pre.10",
"com.unity.multiplayer.tools": "1.0.0",
"com.unity.netcode.gameobjects": "1.0.2",
"com.unity.services.authentication": "1.0.0-pre.4",
"com.unity.services.lobby": "1.0.0-pre.6",
"com.unity.services.relay": "1.0.2"
}
},
"com.unity.multiplayer.tools": {
"version": "1.0.0-pre.7",
"version": "1.0.0",
"depth": 0,
"source": "registry",
"dependencies": {
Expand All @@ -142,12 +142,12 @@
"url": "https://packages.unity.com"
},
"com.unity.netcode.gameobjects": {
"version": "1.0.0-pre.10",
"version": "1.0.2",
"depth": 0,
"source": "registry",
"dependencies": {
"com.unity.nuget.mono-cecil": "1.10.1",
"com.unity.transport": "1.1.0"
"com.unity.transport": "1.2.0"
},
"url": "https://packages.unity.com"
},
Expand Down Expand Up @@ -353,7 +353,7 @@
"url": "https://packages.unity.com"
},
"com.unity.transport": {
"version": "1.1.0",
"version": "1.2.0",
"depth": 1,
"source": "registry",
"dependencies": {
Expand Down

0 comments on commit 554bbeb

Please sign in to comment.