-
Notifications
You must be signed in to change notification settings - Fork 460
Description
Description
A clear and concise description of what the bug is.
Reproduce Steps
- Tested with only the host.
- Called a ServerRPC
- See error, can't find the cause/null reference
Actual Outcome
NullReferenceException: Object reference not set to an instance of an object
Unity.Netcode.NetworkBehaviour.__endSendRpc (Unity.Netcode.FastBufferWriter& bufferWriter, System.UInt32 rpcMethodId, Unity.Netcode.RpcParams rpcParams, Unity.Netcode.RpcAttribute+RpcAttributeParams attributeParams, Unity.Netcode.SendTo defaultTarget, Unity.Netcode.RpcDelivery rpcDelivery) (at ./Library/PackageCache/com.unity.netcode.gameobjects@c690afa8ab6e/Runtime/Core/NetworkBehaviour.cs:354)
NetUI.AddName_ServerRpc (System.String name) (at Assets/Scripts/Networking/NetUI.cs:19)
SceneControl.AddPlayer () (at Assets/Scripts/GameState/SceneControl.cs:17)
PlayerController.OnEnable () (at Assets/Scripts/Player/PlayerController.cs:32)
UnityEngine.Behaviour:set_enabled(Boolean)
Enabler:Enable(Int32) (at Assets/Scripts/Player/Enabler.cs:18)
Enabler:OnNetworkSpawn() (at Assets/Scripts/Player/Enabler.cs:11)
Unity.Netcode.NetworkBehaviour:NetworkSpawn() (at ./Library/PackageCache/com.unity.netcode.gameobjects@c690afa8ab6e/Runtime/Core/NetworkBehaviour.cs:814)
Unity.Netcode.NetworkObject:InvokeBehaviourNetworkSpawn() (at ./Library/PackageCache/com.unity.netcode.gameobjects@c690afa8ab6e/Runtime/Core/NetworkObject.cs:2553)
Unity.Netcode.NetworkSpawnManager:SpawnNetworkObjectLocallyCommon(NetworkObject, UInt64, Boolean, Boolean, UInt64, Boolean) (at ./Library/PackageCache/com.unity.netcode.gameobjects@c690afa8ab6e/Runtime/Spawning/NetworkSpawnManager.cs:1208)
Unity.Netcode.NetworkSpawnManager:AuthorityLocalSpawn(NetworkObject, UInt64, Boolean, Boolean, UInt64, Boolean) (at ./Library/PackageCache/com.unity.netcode.gameobjects@c690afa8ab6e/Runtime/Spawning/NetworkSpawnManager.cs:1104)
Unity.Netcode.NetworkConnectionManager:HandleConnectionApproval(UInt64, Boolean, Nullable1, Nullable1, Nullable`1) (at ./Library/PackageCache/com.unity.netcode.gameobjects@c690afa8ab6e/Runtime/Connection/NetworkConnectionManager.cs:987)
Unity.Netcode.NetworkManager:HostServerInitialize() (at ./Library/PackageCache/com.unity.netcode.gameobjects@c690afa8ab6e/Runtime/Core/NetworkManager.cs:1508)
Unity.Netcode.NetworkManager:StartHost() (at ./Library/PackageCache/com.unity.netcode.gameobjects@c690afa8ab6e/Runtime/Core/NetworkManager.cs:1466)
Buttons:Host() (at Assets/Scripts/GameState/Buttons.cs:12)
UnityEngine.EventSystems.EventSystem:Update() (at ./Library/PackageCache/com.unity.ugui@f33505fcd0e6/Runtime/UGUI/EventSystem/EventSystem.cs:514)
Expected Outcome
RPC to work, as it was given variables
Code Snipets
public int AddPlayer()
{
netUI.AddName_ServerRpc(chat.GetName(playerScores.Value.Count));
AddPlayer_ServerRpc();
return playerScores.Value.Count;
}
[Rpc(SendTo.Server, InvokePermission = RpcInvokePermission.Everyone)]
public void AddPlayer_ServerRpc()
{
playerScores.Value.Add(0);
}
Environment
- OS: [Windows]
- Unity Version: [e.g. 6000.2.3f1]
- Netcode Version: [2.10.0 ]
- Netcode Commit: [e.g. https://github.com/Unity-Technologies/com.unity.netcode.gameobjects/commit/ba418fa5b600ad9eb61fab0575f12fbecc2c6520]
- Netcode Topology: [Default Unity Transport, ]
Additional Context
Add any other context about the problem here. Logs, code snippets would be useful here but please also consider attaching a minimal Unity project that reproduces the issue.