- Home /
Set a spezific spawn position for object as client
First my name is Bastian and excuses my low english skills, but my question is still simpel. In order to be able to better understand the situation, it becomes a strategy game...
At first, i'll list the processes:
There are different parameters. At first a Vector3 position you place as a player with the mouse... no problem works fine. The Second is a prefab, for a example the building you want do build on the spezific position, you did set with the mouse. Instantiate(Building, the spezific Vector3 position, quaternion.identity) And so on...
In the Network processes it looks like: First register the spawnable building-prefab in the lobby, network manager... and so on, easy, check. Second in the player script you set the spawn-command, for example:
{ public Gameobject PrefabBuildingObject; private Vector3 point; // Remember you set them coordinates with the mouse... works
[Command] void CmdBuildTheBuilding() {
GameObject BuildingObject = (GameObject)Instantiate(PrefabBuildingObject, point, Quaternion.identity);
NetworkServer.Spawn(BuildingObject);
}
Now the problem is: As host everything works. The host determines the point where he wants to spawn the building and the building spawn at this position... But all the oder Clients share the same problem. Theire buildings all spawn at position Vector3 (0,0,0)... always!
I am despairing. How can I tell the server to spawn the object on the position I wanted as client?