Destroying non-instantiated objects

I have a game that has a lot of objects that need to be destroyed across all players. PhotonNetwork.Instantiate isn't ideal because it forces me to create them at run-time. This increases the initial processor usage on load, sometimes freezing. Also, its a pain to lay it out in pure code, rather than perfectly placed and visualized in a level.

A few options I've considered:
  • Place markers in unity, then at runtime, PhotonNetwork.Instantiate the objects at the marker's location.
  • Places the actual objects and send an RPC that destroys the object on each player using an array ID match.

Anyone else doing this? What are the best practices handling this?

Comments

  • I think there are two more options:

    3. add a photonnetwork view onto it and when its meant to be destroyed you simply RPC call that RPC on it, in which case you don't have to pass anything around on it? a scene view id is enough here in this case.

    4. naturally you can also make a central 'destruction manager' with an array of game objects and then make that one send the destroy RPC call with the index of the object in the array. As the array would be defined in the editor, the order is granted to be the same for all clients and it would work too

    -> both seem to be much more efficient and maintainable than yours (your option 1 would otherwise be what I would do though not for things that aren't dynamically spawned)
Sign In or Register to comment.