Hello folks! I’ve been getting this error recently, http://hastebin.com/boxacayeno.tex. It seems to be caused by this script, http://hastebin.com/gejinikeda.cs. I’ve been looking at past threads with the same issues but I can’t see what I’m doing wrong…
I believe the error may be because of my Synced List. Am I doing this wrong?
You cannot have a NetworkConnection member variable in the struct for the SyncList.
Thank you for the reply Sean. Do I then have to just store the connection id and loop through every connection in the server and check if the id is the same as the current connection id to find the NetworkConnection?
Why do you want the connection? NetworkBehaviour already has a connectionToClient property.
I guess I could just use the ID to search through the list of player’s to find the player instead of getting the NetworkConnection. I was really only storing the connection to find the connection through the player list. Thanks for the help Sean!
When would you want to do that? When don’t you have the current player context? That sounds like the wrong way to use connectionIds.
I need to search through the list of players to find the correct connection because it contains the UserUI gameobject and my players when they spawn look for their UserUI gameobject so they can modify it’s values so everyone can see their health, icon, etc.
Is this the wrong way to go about storing and locating gameobjects for each player?
There is a “Callback” delegate on SyncLists that allows notifcations on the client when the list changes, you could avoid the RefreshObjects() call by using that delegate.
is RefreshObjects supposed to run on the server or on the client?
Anyway, it looks like you would be better off putting a script on your player object and creating the UI in OnStartClient.
RefreshObjects is supposed to run on the server I guess I should add a server attribute. I am going with this method because I can expand it to contain more information of the player.