Skip to content

NetworkTransform child in prefab spawns at wrong position for other players under certain conditions #3082

@SubatomicPlanets

Description

@SubatomicPlanets

Description

When I talk about the childs position here I always mean the local space relative to it's parent.

I have a player prefab with a NetworkObject component and a NetworkTransform. I then have another gameObject(a sphere) as a child of this. The child also has a NetworkTransform and I moved it to 2,2,0 to be in a different position than the parent. Both NetworkTransforms are owner-authoritative. The NetworkTransform on the child also has "In Local Space" set to true.
When I start as host everything works fine. I see the prefab spawn at 0,0,0 and it's child at 2,2,0. When I start another player as a client it also works and both player prefabs are at 0,0,0 and the children at 2,2,0.

However, when I set the position of the actual prefab root to 1,1,1 strange things start happening. It also happens if I keep it at 0,0,0 and use connection approval to set the players position to 1,1,1 (but connection approval is kinda broken in 2.0.0, so for that example I used the develop-2.0.0 branch where connection approval is fixed)
So when I then start the host it seems fine (player spawns at 1,1,1 with child at 2,2,0). When I now start a client it also does the same. But this time the host displays the clients player wrong. The clients player is at 1,1,1 but the child is at 1,1,-1 instead of 2,2,0.

Basically the position of NetworkTransforms on children of my player prefab get synchronized wrongly if "In Local Space" is set to true, it is owner-authoritative, and the player doesn't spawn at 0,0,0 (I don't know if that all the requirements to reproduce it but I think so).
This is a strange issue and I don't really know how to put it into words... I came across it in my game where the player prefab has hands that have NetworkTransforms. The player spawned at a spawn point but the hands were at some strange location.

Reproduce Steps

  1. Use the Bootstrap sample
  2. Add another gameObject (like a sphere or cube) with a NetworkTransform as a child in the player prefab
  3. Move the child object a bit (I set it to 2,2,0) so that it's offset from its parent
  4. Set both NetworkTransforms to be owner-authoritative
  5. Set "In Local Space" on the childs NetworkTransform to be true
  6. Set the position of the player prefab to something else than 0,0,0 (or use connection approval to set the position using the develop-2.0.0 branch)

Actual Outcome

The player prefab spawns correctly but the children inside spawn at strange positions for other players

Expected Outcome

The children should spawn correctly

Environment

  • OS: Windows
  • Unity Version: 6000.0.20f1
  • Netcode Version: 2.0.0

Metadata

Metadata

Labels

priority:highThis issue has high priority and we are focusing to resolve itstat:importStatus - Issue is going to be saved internallytype:bugBug Report

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions