Clients destroying a gameObject over the network owned by the server

Options
Is there a way to let a client BoltNetwork.Destroy() a gameObject they don't own?

I've tried having the client tell the server to destroy the object through something like a state.Tag or a trigger state but nothing goes through. Only the owner of the object was able to change the state.Tag or call a trigger state.

There's probably a really simple way to do this that I'm just not seeing.

Comments

  • Hello @chocomurr ,

    Yes, the authority over an entity is guaranteed, so only the owner of it can change its state and destroy it.

    One solution would be the "ask" the Owner of an entity to destroy it using Events (https://doc.photonengine.com/en-us/bolt/current/gameplay/events).

    1. Get the reference of the `BoltEntity` component from your Target Entity;
    2. Check if you are the owner of that Entity, if yes, destroy it;
    3. If not, look at the `Source` property of the `BoltEntity` (https://doc-api.photonengine.com/en/bolt/current/class_bolt_entity.html#a7aebe2c489a211619a8bffec34c75194). This will contain from which connection you've received that entity. Send a "DestroyRequest" event (your custom event) to that connection.
    4. When receiving the event, repeat from step 2.

    This way, you will guarantee that your event will eventually reach the Owner of that entity in order to destroy it. And of course, also give the Owner the chance to just discard the request, for example.
  • Thank you for the quick response. This is exactly what I was looking for.