I initially posted this to the MP forums here but haven’t had any luck figuring this out. The issue I am running into is with accessing or initializing a SyncList object that has been declared in a base class. Lets say I have something like this in my base class ThowableItem.cs
protected SyncListFloat inaccuracy = new SyncListFloat();
As long as I utilize this object within the ThrowableItem class everything works fine! However if I declare ThrowableItem.cs->Ball.cs and then attempt to access the inaccuracy element from Ball.cs I get an error that the sync list is uninitialized. This occurs even when attempting to access the inaccuracy object from a call to a base method. Here’s the code running in OnStartServer generating the error from ThrowableItem.cs:OnStartServer when called from Ball.cs
// inaccuracy = new SyncListFloat();
for (int count = 0; count < bagSize; count++)
inaccuracy.Add(Random.Range(-inaccuracyRange, inaccuracyRange));
I also tried moving the initialization out the base class. I figured I would just initialize the variable declared in the base class in the descendant and everything would work. Nope, same error, synclist uninitialized. Do SyncLists need to be initialized within class scope and not method scope? How is it recommended to declare and initialize synclists for use with inheritance and polymorphism? I can’t seem to figure out how to correctly use these things within a class hierarchy.