What is the solution for this problem ?
I’d say initialise connectionToClient. Hard to know for sure with what’s here. Maybe the connection has fallen out, but I’d guess the former.
That’s of course assuming you’re showing the script in question.
I get the connectionId but when I check the connectionToclient.connectionId it is null.
That wouldn’t generate that error, only if connectionToClient itself is null.
connectionId in this method is coming from the UnitBase, so you are saying that connection is not null?
connectionToClient.connectionId is the one from the health script, that is the on you are saying is null?
What version of Mirror and Unity are you using?
Does the gameObject with the health component throwing the error have a network identity component attached?
fwiw, only connectionToClient
can be null. connectionId
(both the parameter, and the property) is an integer and cannot be null. It’s not possible unless they were declared as int?
or Nullable<int>
, and they weren’t. I checked.