Spawn Object

Options
Hello!

I have a question about instantiating objects. I can collect an object:

private void OnTriggerEnter(Collider other) { if (other.gameObject.tag == "Player") { gameObject.SetActive(false); PhotonView photonView = other.GetComponent<PhotonView>(); if (photonView.isMine) { print("Pick up item!"); } } } }

Now I want the object to disappear for a few minutes and spawn again. My question is, how do I do this?

I would have to set a timer somewhere, for example with the master client. But what if the master client leaves the game? Then the object would not be spawned anymore?

Can someone help me?

Thank you!

Comments

  • Hi @Anubis,

    Now I want the object to disappear for a few minutes and spawn again. My question is, how do I do this?


    You basically have two different options in this case: the first is to just disable the object and to enable it again later on, the other is to destroy the object and instantiate it again later on. If this object is not available for a few minutes I would prefer destroying it.

    Destroying a networked object works by using PhotonNetwork.Destroy(...). Please note that a networked object can only be destroyed by it's owner.