Skip to content

Commit 96509f1

Browse files
Merge branch 'develop' into fix/netvar-dropping-changes-khyperia
2 parents d01003b + 11dcd06 commit 96509f1

File tree

12 files changed

+482
-172
lines changed

12 files changed

+482
-172
lines changed

.yamato/wrench/api-validation-jobs.yml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,14 +13,14 @@ api_validation_-_netcode_gameobjects_-_2021_3_-_windows:
1313
type: Unity::VM
1414
flavor: b1.large
1515
commands:
16-
- command: curl https://artifactory.prd.it.unity3d.com/artifactory/stevedore-unity-internal/wrench-localapv/1-2-61_6af0746012fdbe27c8d9841fcad8f97465d1943826d6884e6aabf0d289b83093.zip -o wrench-localapv.zip
16+
- command: curl https://artifactory.prd.it.unity3d.com/artifactory/stevedore-unity-internal/wrench-localapv/1-2-68_53c92d3b34ce3f4b652c9785dd1530bdc5885f6523465d6969c3be91f9ccaaf1.zip -o wrench-localapv.zip
1717
- command: 7z x -aoa wrench-localapv.zip
1818
- command: pip install semver requests --index-url https://artifactory-slo.bf.unity3d.com/artifactory/api/pypi/pypi/simple
1919
- command: python PythonScripts/print_machine_info.py
2020
- command: npm install upm-ci-utils@stable -g --registry https://artifactory.prd.cds.internal.unity3d.com/artifactory/api/npm/upm-npm
2121
timeout: 20
2222
retries: 10
23-
- command: unity-downloader-cli -u 2021.3 -c Editor --fast
23+
- command: unity-downloader-cli -u 2021.3/staging -c Editor --fast
2424
timeout: 10
2525
retries: 3
2626
- command: python PythonScripts/PackageJsonCondersor.py
@@ -51,8 +51,8 @@ api_validation_-_netcode_gameobjects_-_2021_3_-_windows:
5151
dependencies:
5252
- path: .yamato/wrench/package-pack-jobs.yml#package_pack_-_netcode_gameobjects
5353
variables:
54-
UPMPVP_CONTEXT_WRENCH: 0.10.48.0
54+
UPMPVP_CONTEXT_WRENCH: 0.11.1.0
5555
metadata:
5656
Job Maintainers: '#rm-packageworks'
57-
Wrench: 0.10.48.0
57+
Wrench: 0.11.1.0
5858

.yamato/wrench/package-pack-jobs.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,5 +24,5 @@ package_pack_-_netcode_gameobjects:
2424
UPMCI_ACK_LARGE_PACKAGE: 1
2525
metadata:
2626
Job Maintainers: '#rm-packageworks'
27-
Wrench: 0.10.48.0
27+
Wrench: 0.11.1.0
2828

.yamato/wrench/preview-a-p-v.yml

Lines changed: 73 additions & 73 deletions
Large diffs are not rendered by default.

.yamato/wrench/promotion-jobs.yml

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ publish_dry_run_netcode_gameobjects:
99
type: Unity::VM
1010
flavor: b1.large
1111
commands:
12-
- command: curl https://artifactory.prd.it.unity3d.com/artifactory/stevedore-unity-internal/wrench-localapv/1-2-61_6af0746012fdbe27c8d9841fcad8f97465d1943826d6884e6aabf0d289b83093.zip -o wrench-localapv.zip
12+
- command: curl https://artifactory.prd.it.unity3d.com/artifactory/stevedore-unity-internal/wrench-localapv/1-2-68_53c92d3b34ce3f4b652c9785dd1530bdc5885f6523465d6969c3be91f9ccaaf1.zip -o wrench-localapv.zip
1313
- command: 7z x -aoa wrench-localapv.zip
1414
- command: pip install semver requests --index-url https://artifactory-slo.bf.unity3d.com/artifactory/api/pypi/pypi/simple
1515
- command: python PythonScripts/print_machine_info.py
@@ -208,10 +208,10 @@ publish_dry_run_netcode_gameobjects:
208208
ignore_artifact: true
209209
variables:
210210
UPMPVP_ACK_UPMPVP_DOES_NO_API_VALIDATION: 1
211-
UPMPVP_CONTEXT_WRENCH: 0.10.48.0
211+
UPMPVP_CONTEXT_WRENCH: 0.11.1.0
212212
metadata:
213213
Job Maintainers: '#rm-packageworks'
214-
Wrench: 0.10.48.0
214+
Wrench: 0.11.1.0
215215

216216
# Publish for netcode.gameobjects to https://artifactory-slo.bf.unity3d.com/artifactory/api/npm/upm-npm
217217
publish_netcode_gameobjects:
@@ -221,7 +221,7 @@ publish_netcode_gameobjects:
221221
type: Unity::VM
222222
flavor: b1.large
223223
commands:
224-
- command: curl https://artifactory.prd.it.unity3d.com/artifactory/stevedore-unity-internal/wrench-localapv/1-2-61_6af0746012fdbe27c8d9841fcad8f97465d1943826d6884e6aabf0d289b83093.zip -o wrench-localapv.zip
224+
- command: curl https://artifactory.prd.it.unity3d.com/artifactory/stevedore-unity-internal/wrench-localapv/1-2-68_53c92d3b34ce3f4b652c9785dd1530bdc5885f6523465d6969c3be91f9ccaaf1.zip -o wrench-localapv.zip
225225
- command: 7z x -aoa wrench-localapv.zip
226226
- command: pip install semver requests --index-url https://artifactory-slo.bf.unity3d.com/artifactory/api/pypi/pypi/simple
227227
- command: python PythonScripts/print_machine_info.py
@@ -420,8 +420,8 @@ publish_netcode_gameobjects:
420420
ignore_artifact: true
421421
variables:
422422
UPMPVP_ACK_UPMPVP_DOES_NO_API_VALIDATION: 1
423-
UPMPVP_CONTEXT_WRENCH: 0.10.48.0
423+
UPMPVP_CONTEXT_WRENCH: 0.11.1.0
424424
metadata:
425425
Job Maintainers: '#rm-packageworks'
426-
Wrench: 0.10.48.0
426+
Wrench: 0.11.1.0
427427

.yamato/wrench/recipe-regeneration.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,5 +26,5 @@ test_-_wrench_jobs_up_to_date:
2626
cancel_old_ci: true
2727
metadata:
2828
Job Maintainers: '#rm-packageworks'
29-
Wrench: 0.10.48.0
29+
Wrench: 0.11.1.0
3030

.yamato/wrench/validation-jobs.yml

Lines changed: 72 additions & 72 deletions
Large diffs are not rendered by default.

.yamato/wrench/wrench_config.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@
3131
},
3232
"publishing_job": ".yamato/wrench/promotion-jobs.yml#publish_netcode_gameobjects",
3333
"branch_pattern": "ReleaseSlash",
34-
"wrench_version": "0.10.48.0",
34+
"wrench_version": "0.11.1.0",
3535
"pvp_exemption_path": ".yamato/wrench/pvp-exemptions.json",
3636
"cs_project_path": "Tools\\CI\\NGO.Cookbook.csproj"
3737
}

Tools/CI/NGO.Cookbook.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
</PropertyGroup>
99

1010
<ItemGroup>
11-
<PackageReference Include="RecipeEngine.Modules.Wrench" Version="0.10.48" />
11+
<PackageReference Include="RecipeEngine.Modules.Wrench" Version="0.11.1" />
1212
</ItemGroup>
1313

1414
</Project>

com.unity.netcode.gameobjects/Runtime/Core/NetworkObject.cs

Lines changed: 26 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -417,6 +417,24 @@ private GlobalObjectId GetGlobalId()
417417
/// </summary>
418418
public bool AutoObjectParentSync = true;
419419

420+
/// <summary>
421+
/// Determines if the owner will apply transform values sent by the parenting message.
422+
/// </summary>
423+
/// <remarks>
424+
/// When enabled, the resultant parenting transform changes sent by the authority will be applied on all instances. <br />
425+
/// When disabled, the resultant parenting transform changes sent by the authority will not be applied on the owner's instance. <br />
426+
/// When disabled, all non-owner instances will still be synchronized by the authority's transform values when parented.
427+
/// </remarks>
428+
[Tooltip("When disabled (default enabled), the owner will not apply a server or host's transform properties when parenting changes. Primarily useful for client-server network topology configurations.")]
429+
public bool SyncOwnerTransformWhenParented = true;
430+
431+
/// <summary>
432+
/// Client-Server specific, when enabled an owner of a NetworkObject can parent locally as opposed to requiring the owner to notify the server it would like to be parented.
433+
/// This behavior is always true when using a distributed authority network topology and does not require it to be set.
434+
/// </summary>
435+
[Tooltip("When enabled (default disabled), owner's can parent a NetworkObject locally without having to send an RPC to the server or host. Only pertinent when using client-server network topology configurations.")]
436+
public bool AllowOwnerToParent;
437+
420438
internal readonly HashSet<ulong> Observers = new HashSet<ulong>();
421439

422440
#if MULTIPLAYER_TOOLS
@@ -1086,8 +1104,9 @@ public bool TrySetParent(NetworkObject parent, bool worldPositionStays = true)
10861104
{
10871105
return false;
10881106
}
1089-
1090-
if (!NetworkManager.IsServer && !NetworkManager.ShutdownInProgress)
1107+
// If we don't have authority and we are not shutting down, then don't allow any parenting.
1108+
// If we are shutting down and don't have authority then allow it.
1109+
if (!(NetworkManager.IsServer || (AllowOwnerToParent && IsOwner)) && !NetworkManager.ShutdownInProgress)
10911110
{
10921111
return false;
10931112
}
@@ -1102,6 +1121,8 @@ public bool TrySetParent(NetworkObject parent, bool worldPositionStays = true)
11021121
return false;
11031122
}
11041123

1124+
1125+
11051126
m_CachedWorldPositionStays = worldPositionStays;
11061127

11071128
if (parent == null)
@@ -1135,7 +1156,9 @@ private void OnTransformParentChanged()
11351156
return;
11361157
}
11371158

1138-
if (!NetworkManager.IsServer)
1159+
var hasAuthority = NetworkManager.IsServer || (AllowOwnerToParent && IsOwner);
1160+
1161+
if (!hasAuthority)
11391162
{
11401163
// Log exception if we are a client and not shutting down.
11411164
if (!NetworkManager.ShutdownInProgress)

com.unity.netcode.gameobjects/Runtime/Messaging/Messages/ParentSyncMessage.cs

Lines changed: 32 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -106,19 +106,42 @@ public void Handle(ref NetworkContext context)
106106
networkObject.SetNetworkParenting(LatestParent, WorldPositionStays);
107107
networkObject.ApplyNetworkParenting(RemoveParent);
108108

109-
// We set all of the transform values after parenting as they are
110-
// the values of the server-side post-parenting transform values
111-
if (!WorldPositionStays)
109+
110+
// This check is primarily for client-server network topologies when the motion model is owner authoritative:
111+
// When SyncOwnerTransformWhenParented is enabled, then always apply the transform values.
112+
// When SyncOwnerTransformWhenParented is disabled, then only synchronize the transform on non-owner instances.
113+
if (networkObject.SyncOwnerTransformWhenParented || (!networkObject.SyncOwnerTransformWhenParented && !networkObject.IsOwner))
112114
{
113-
networkObject.transform.localPosition = Position;
114-
networkObject.transform.localRotation = Rotation;
115+
// We set all of the transform values after parenting as they are
116+
// the values of the server-side post-parenting transform values
117+
if (!WorldPositionStays)
118+
{
119+
networkObject.transform.localPosition = Position;
120+
networkObject.transform.localRotation = Rotation;
121+
}
122+
else
123+
{
124+
networkObject.transform.position = Position;
125+
networkObject.transform.rotation = Rotation;
126+
}
115127
}
116-
else
128+
networkObject.transform.localScale = Scale;
129+
130+
// If client side parenting is enabled and this is the server instance, then notify the rest of the connected clients that parenting has taken place.
131+
if (networkObject.AllowOwnerToParent && context.SenderId == networkObject.OwnerClientId && networkManager.IsServer)
117132
{
118-
networkObject.transform.position = Position;
119-
networkObject.transform.rotation = Rotation;
133+
var size = 0;
134+
var message = this;
135+
foreach (var client in networkManager.ConnectedClients)
136+
{
137+
if (client.Value.ClientId == networkObject.OwnerClientId || client.Value.ClientId == networkManager.LocalClientId || !networkObject.IsNetworkVisibleTo(client.Value.ClientId))
138+
{
139+
continue;
140+
}
141+
size = networkManager.ConnectionManager.SendMessage(ref message, NetworkDelivery.ReliableSequenced, client.Value.ClientId);
142+
networkManager.NetworkMetrics.TrackOwnershipChangeSent(client.Key, networkObject, size);
143+
}
120144
}
121-
networkObject.transform.localScale = Scale;
122145
}
123146
}
124147
}

0 commit comments

Comments
 (0)