Hi there,
I’m getting a NullReferenceException when calling in the Unit.cs script when I try to invoke the Action on “this” object.
Here’s the error output.
NullReferenceException: Object reference not set to an instance of an object
RTS.Networking.RTSPlayer.ServerHandleUnitSpawned (RTS.Units.Unit unit) (at Assets/Scripts/Networking/RTSPlayer.cs:29)
RTS.Units.Unit.OnStartServer () (at Assets/Scripts/Units/Unit.cs:32)
Mirror.NetworkIdentity.OnStartServer () (at Assets/Mirror/Runtime/NetworkIdentity.cs:673)
UnityEngine.Debug:LogException(Exception, Object)
Mirror.NetworkIdentity:OnStartServer() (at Assets/Mirror/Runtime/NetworkIdentity.cs:677)
Mirror.NetworkServer:SpawnObject(GameObject, NetworkConnection) (at Assets/Mirror/Runtime/NetworkServer.cs:1090)
Mirror.NetworkServer:Spawn(GameObject, NetworkConnection) (at Assets/Mirror/Runtime/NetworkServer.cs:1116)
RTS.Buildings.UnitSpawner:UserCode_CmdSpawUnits() (at Assets/Scripts/Buildings/UnitSpawner.cs:20)
RTS.Buildings.UnitSpawner:InvokeUserCode_CmdSpawUnits(NetworkBehaviour, NetworkReader, NetworkConnectionToClient)
Mirror.RemoteCalls.RemoteProcedureCalls:Invoke(Int32, RemoteCallType, NetworkReader, NetworkBehaviour, NetworkConnectionToClient) (at Assets/Mirror/Runtime/RemoteCalls.cs:120)
Mirror.NetworkIdentity:HandleRemoteCall(Byte, Int32, RemoteCallType, NetworkReader, NetworkConnectionToClient) (at Assets/Mirror/Runtime/NetworkIdentity.cs:1091)
Mirror.NetworkServer:OnCommandMessage(NetworkConnectionToClient, CommandMessage, Int32) (at Assets/Mirror/Runtime/NetworkServer.cs:979)
Mirror.<>c__DisplayClass6_0`2:<WrapHandler>b__0(NetworkConnection, NetworkReader, Int32) (at Assets/Mirror/Runtime/MessagePacking.cs:126)
Mirror.NetworkServer:UnpackAndInvoke(NetworkConnectionToClient, NetworkReader, Int32) (at Assets/Mirror/Runtime/NetworkServer.cs:470)
Mirror.NetworkServer:OnTransportData(Int32, ArraySegment`1, Int32) (at Assets/Mirror/Runtime/NetworkServer.cs:533)
Mirror.LocalConnectionToServer:Send(ArraySegment`1, Int32) (at Assets/Mirror/Runtime/LocalConnectionToServer.cs:45)
Mirror.NetworkConnection:Send(CommandMessage, Int32) (at Assets/Mirror/Runtime/NetworkConnection.cs:139)
Mirror.NetworkBehaviour:SendCommandInternal(String, NetworkWriter, Int32, Boolean) (at Assets/Mirror/Runtime/NetworkBehaviour.cs:248)
RTS.Buildings.UnitSpawner:CmdSpawUnits()
RTS.Buildings.UnitSpawner:OnPointerClick(PointerEventData) (at Assets/Scripts/Buildings/UnitSpawner.cs:32)
UnityEngine.EventSystems.EventSystem:Update() (at Library/PackageCache/com.unity.ugui@1.0.0/Runtime/EventSystem/EventSystem.cs:501)