Unity-Technologies / com.unity.netcode.gameobjects

Netcode for GameObjects is a high-level netcode SDK that provides networking capabilities to GameObject/MonoBehaviour workflows within Unity and sits on top of underlying transport layer.
MIT License
2.14k stars 434 forks source link

InstantiateAndSpawn ignores supplied isPlayerObject variable #2990

Closed Nyphur closed 1 month ago

Nyphur commented 2 months ago

The NetworkSpawnManager.InstantiateAndSpawn method takes in a bool isPlayerObject, but the spawn code overwrites this to false every time.

You can see here that it sets IsPlayerObject based on the supplied variable and then calls SpawnWithOwnership which calls SpawnInternal: https://github.com/Unity-Technologies/com.unity.netcode.gameobjects/blob/440039027311ff10b900480884b64a574d9b3028/com.unity.netcode.gameobjects/Runtime/Spawning/NetworkSpawnManager.cs#L412

And here you can see that SpawnInternal just automatically passes in false as the isPlayerObject: https://github.com/Unity-Technologies/com.unity.netcode.gameobjects/blob/440039027311ff10b900480884b64a574d9b3028/com.unity.netcode.gameobjects/Runtime/Core/NetworkObject.cs#L873

NoelStephensUnity commented 2 months ago

@Nyphur I believe this issue was resolved in PR-2968. The most recent version of NGO (v1.10.0) should contain this fix.

Let me know if this resolves your issue?

Nyphur commented 2 months ago

Thanks, that does seem like it may solve the issue in that version. Unfortunately it doesn't work for most ongoing projects as 1.10 is targeting Unity 6.0+ and later, will have to just use a workaround.

NoelStephensUnity commented 1 month ago

@Nyphur NGO v1.x versions target 2022.3 and Unity 6. You should be able to use NGO v1.10.0 on 2022.3.