com.unity.netcode.gameobjects icon indicating copy to clipboard operation
com.unity.netcode.gameobjects copied to clipboard

InstantiateAndSpawn ignores supplied isPlayerObject variable

Open Nyphur opened this issue 1 year ago • 2 comments

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

Nyphur avatar Jul 26 '24 19:07 Nyphur

@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?

NoelStephensUnity avatar Jul 29 '24 14:07 NoelStephensUnity

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.

Nyphur avatar Aug 05 '24 18:08 Nyphur

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

NoelStephensUnity avatar Sep 02 '24 22:09 NoelStephensUnity