So I also put a video to show what’s happening, now when I look at the worker unit for the client, the generator is null until the host building is up.
Maybe I need to do a hasAuthority somewhere for the building list but I was thinking the player connection would have taken care of that.
here is the code on the worker unit, update
private void Start()
{
player = NetworkClient.connection.identity.GetComponent<RTSPlayer>();
}
private void Update()
{
GatherNode gatherNode = worker.GetGather();
timeSinceLastGather += Time.deltaTime;
LookForBuilding();
GatheringAction();
if (gatherNode != null && startGathering == true)
{
if(!CanGatherTarget()) {return;}
Quaternion targetRotation = Quaternion.LookRotation(
gatherNode.transform.position - transform.position);
transform.rotation = Quaternion.RotateTowards(
transform.rotation, targetRotation, rotationSpeed * Time.deltaTime);
if (timeSinceLastGather > gatherRate)
{
UpdateGatherAnimation();
timeSinceLastGather = 0;
}
}
if (generator != null && deliverStack == true)
{
if(!CanDeliverStack()){return;}
Quaternion targetRotation = Quaternion.LookRotation(
generator.transform.position - transform.position);
transform.rotation = Quaternion.RotateTowards(
transform.rotation, targetRotation, rotationSpeed * Time.deltaTime);
if (timeSinceLastGather > gatherRate)
{
UpdateDeliverAnimation();
timeSinceLastGather = 0;
}
}
}
private void LookForBuilding()
{
foreach(Building building in player.GetMyBuildings())
{
if (building.GetId() == genID)
{
ResourceGenerator reGen = building.GetComponent<ResourceGenerator>();
generator = reGen;
}
}
}
[SerializeField] private ResourceGenerator generator = null;
this is null until the look for building updates it, it works with the host units but the joined player unit doesn’t take in the building, one time I notice it take in the host building instead.