Skip to content

fix: player networkobject not added to client owned object list #1801

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Conversation

NoelStephensUnity
Copy link
Collaborator

@NoelStephensUnity NoelStephensUnity commented Mar 14, 2022

This PR primarily addresses the issue where player NetworkObjects were not being added to the NetworkClients OwnedObjects list. However, it was also discovered that dynamically spawned NetworkObjects were not properly updating the NetworkClients OwnedObjects list as it was only updating this list if the ChangeOwnership or RemoveOwnership messages were sent (but not spawn messages).
This update fixes both issues by creating a NetworkSpawnManager.OwnershipToObjectsTable that is updated for all clients on the server-side and only for the owned objects of the client on the client-side.

MTT-1585

Changelog

com.unity.netcode.gameobjects

  • Fixed: Player objects and dynamically spawned NetworkObjects not being added to the client's owned objects list.

Testing and Documentation

  • Includes modified integration tests.
  • Includes integration tests.

NoelStephensUnity and others added 9 commits March 14, 2022 11:21
This fixes the issue with a player not being added to the client's owned objects list.  This also fixes the issue where dynamically spawned NetworkObjects were not getting added to the client's owned object list.
This fix migrates the table into NetworkSpawnManager, removes the OwnedObjects list from NetworkClient (replaces it with a method), and provides automatic assignment and de-assignment of ownership to the NetworkSpawnManager's OwnershipToObjectsTable.
Updates some of the ownership integration tests to the changes.
Log message and exception additions.
White space removal.
Extra-LF removal.
removed extra '}' char.
Fix for server ownership invocation.
whitespace
@0xFA11 0xFA11 self-requested a review March 14, 2022 20:10
Fixing minor issue with NetworkTransform having ownership applied before OnNetworkSpawn being invoked.
{
return PlayerObject.NetworkManager.SpawnManager.GetClientOwnedObjects(ClientId);
}
return null;
Copy link
Contributor

Choose a reason for hiding this comment

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

it might be better to return an empty list instead of null

NoelStephensUnity and others added 17 commits March 14, 2022 16:06
This is the test for this PR
set previous owner whether removing or not.
Set the ownership before invoking lost or gained ownership methods.
fixing some order of operations issues.
reverting back to OwnedObjects get.
removed the internal OwnerClientId.
Removing nullable client id as a parameter in spawn methods.
Minor update to the ownership test where it double checks the update to NetworkClient when checking if a client's player is included in the owned objects list.
Minor clean up.
Assure that clients that are neither the current or new owner of the NetworkObject update their properties to reflect the new owner.
Added a test to verify that switching ownership between several clients works.
@NoelStephensUnity NoelStephensUnity marked this pull request as ready for review March 15, 2022 16:15
NoelStephensUnity and others added 4 commits March 15, 2022 11:22
updating small comment for clarity
updated comments for clarity.
@NoelStephensUnity NoelStephensUnity merged commit ce8f5b8 into develop Mar 15, 2022
@NoelStephensUnity NoelStephensUnity deleted the fix/mtt-1585-player-networkobject-not-in-client-owned-list branch March 15, 2022 19:52
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.

3 participants