Skip to content

fix: mtt-4516 NetworkList change inside OnNetworkSpawn#2181

Merged
jeffreyrainy merged 3 commits intodevelopfrom
fix/mtt-4516
Sep 8, 2022
Merged

fix: mtt-4516 NetworkList change inside OnNetworkSpawn#2181
jeffreyrainy merged 3 commits intodevelopfrom
fix/mtt-4516

Conversation

@jeffreyrainy
Copy link
Copy Markdown
Contributor

changes to the NetworkList inside OnNetworkSpawn results in other clients not catching the change of the values
mtt-4516
#2163

This removes the hack that was need for NetworkList: ListAtLastReset. This hack was needed because the order of operations differed between in-scene placed objects and dynamically spawned object. However, the flow is now the same.

However, fixing this exposed another issue. Upon modifying a NetworkList during spawning, even though the correct list would now be sent, the modify operation would be re-applied at the next modification. So, we added a clear of the dirty state of NetworkVariables upon spawn, on the server.

…ls short as the NetworkBehaviour doesn't yet have its NetworkVariables initialized
…NetworkVariable upon spawn, as it is the logical place to do so
@jeffreyrainy jeffreyrainy requested a review from a team as a code owner September 7, 2022 21:58
public class NetworkList<T> : NetworkVariableBase where T : unmanaged, IEquatable<T>
{
private NativeList<T> m_List = new NativeList<T>(64, Allocator.Persistent);
private NativeList<T> m_ListAtLastReset = new NativeList<T>(64, Allocator.Persistent);
Copy link
Copy Markdown
Collaborator

@ShadauxCat ShadauxCat Sep 7, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Glad to see this not be needed anymore. Good work finding a better solution! 🥳 🎉

@jeffreyrainy jeffreyrainy merged commit b6a68e7 into develop Sep 8, 2022
@jeffreyrainy jeffreyrainy deleted the fix/mtt-4516 branch September 8, 2022 14:18
jakobbbb pushed a commit to GooseGirlGames/com.unity.netcode.gameobjects that referenced this pull request Feb 22, 2023
…ogies#2181)

* fix: Marking NetworkVariable dirty upon spawn on the host/server. Falls short as the NetworkBehaviour doesn't yet have its NetworkVariables initialized

* fix: clearing variable dirty state post spawning. Also, Initializing NetworkVariable upon spawn, as it is the logical place to do so

* test: tests and removing debug logging
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants