I’m making an rts and I’m trying to make it so when the builder goes to a structure and hits a trigger then the building spawns on the server. It works just fine on the host and the client receives it fine but when a client tries to build something, I get RpcCompleteStructure can’t be called on Client.
OnTriggerEnter call this (structure being something in a local arraylist):
[ClientRpc]
private void RpcCompleteStructure(GameObject structure)
{
if (!isLocalPlayer)
{
return;
}
GameObject completedStructure = Instantiate(structure, structure.transform;
Destroy(structure); //spawns built structure and destroys construction site placeholder
NetworkServer.Spawn(completedStructure);
completedStructure .GetComponent<StructureScript>().CompleteBuild(); //completes structure, sets "built" variables
}
StructureScript CompleteBuild:
public void CompleteBuild()
{
GetComponent<UnityEngine.AI.NavMeshObstacle>().enabled = true;
built = true;
Destroy(gameObject.transform.GetChild(0).gameObject);
Destroy(gameObject.transform.GetChild(1).gameObject);
}
I’m new to multiplayer and would appreciate any help with it. Thank you