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.15k stars 435 forks source link

NetworkVariable now trigger warning when used offline #2279

Open PitouGames opened 2 years ago

PitouGames commented 2 years ago

Posted as a Discord forum during Dev-Blitz

Feedback

Me: Since the 1.1.0, an annoying warning pops when I use a NetworkVariable without a NetworkManager in scene: https://github.com/Unity-Technologies/com.unity.netcode.gameobjects/blob/8b2a8b7a5975dc1229d060250df0bb655d11cbc7/com.unity.netcode.gameobjects/Runtime/NetworkVariable/NetworkVariableBase.cs#L88 This warning is great for beginners that missconfigured their project, but not for me that did this on purpose. To me, this is a regression, because I can't use a NetworkVariable for the solo mode anymore. I use NetworkVariables in my project for both Online and Offline (solo) mode, to reduce codebase comprexity. What's your vision on this issue? Should NGO support an offline use of NetworkVariables? How to manage a codebase for both offline and online gaming with NGO? Is there any bitsize project to demonstrate an online project that also works offline? Note that I'm not willing to start a local server (host mode) for a solo player, because it adds some useless overhead.

Leoul: I'm also curious about this change, though unrelated to offline usage. Presumably a dev would want to configure the state of an object before spawning it to make sure it has the correct state before syncing it.

ThusSpokeNomad (Unity staff): I'm not 100% clear on the reasoning behind the Debug.LogWarning change there (it probably should've been NetworkLog.LogWarning anyway) but if we were to convert it to NetworkLog.LogWarning and expect users to turn-off NetworkLogs when not connected to make it disappear in offline mode, would that solve your issue you think? Also FWIW, this thread could be a nice GitHub Issue, either as a feedback or regression bug if you'd think so.**

Jeff (Unity staff): The simplest approach with the current release (and most likely future ones) would be to:

The main advantage of this is that to the solo player, the host, the game is a networked one, it just has the special case of not having any connected player. That guarantees you that when you actually go multi-player there will be no (well, less) surprises.

Me: Yes, this is also what I thought to do to mitigate my issue, but I like the idea of NOT using a NetworkManager when I don't need networking. Furthermore, I think that having a NetworkManager running in Host mode may trigger the Windows Firewall popup (the first time) to allow incoming conection, even for a solo player, which is a bit suspissious and annoying while playing solo. There is the risk the player say "Not allow", and then when hosting later an online game have throubles to let others connect.

Suggested Changes

As ThusSpokeNomad said, please review why we have added this warning, is it really nessesary? If it is nessessary, change it to NetworkLog.LogWarning, so users can mute it, otherwise please remove it.

TheCaveOfWonders commented 1 year ago

this is intended, please see https://github.com/Unity-Technologies/com.unity.netcode.gameobjects/issues/2159