Create Player Controlled Unit
Options
This code is my Player object, CreateShip gets called from a GameManager Object as soon as the game starts:
public void CreateShip()
{
if(photonView.isMine)
{
CmdShipSpawn();
}
}
[PunRPC]
void CmdShipSpawn()
{
int xSpawn = Random.Range(-20, 20);
int zSpawn = Random.Range(-20, 20);
Debug.Log("Spawn Method called");
var myNewShip = Instantiate(playerShip, new Vector3(xSpawn, 1f, zSpawn), Quaternion.identity);
myNewShip.transform.parent = gameObject.transform;
}
Now I struggle to give the player ownership of created ships, they are created as scene objects.
So I need
1) A way to parent ship objects instantiated with PhotonNetwork.Instantiate to the corresponding player object
OR
2) A way to give ownership with the RPC-Call
Thanks for helping
After changing random stuff around the parenting works now
0