Keeping Objects Destroyed

Options
Hello,

I'm working with the Photon Unity Plugin, and I have everything working nicely. I'm trying to have it where when someone deletes an object in the game, it stays deleted. Here's what's happening.


Player 1 logs in.
player 2 logs in.

Two players see a cube on the floor.

Player 1 walks into the cube.

It disappears for both Player 1 and player 2.

I'm using:
PhotonTargets.AllBufferedViaServer
Inside the RPC call.

Player 3 logs in.

No cube is visible to all players. (This is fantastic!)

Player 2 logs out and then back in.

The cube for all players is not visible (This is fantastic!)

Player 1 (who ran into the cube...) logs out and then back in...

The cube reappears for player 1 but is not visible to players 2 and 3. (NOT GOOD!)


Why is this happening?

The way my cube is set up is it's just a cube in the scene, it's not instantiated, and it has a photon view component and a script that checks for OnTriggerEnter. There is a RemoveCube function that has the RPC attribute above it, and when someone calls the scripts Trigger, it runs that code.

It seems that whoever ran into the block to destroy it, if that person logs out and then back in, it's like the whole system resets. Why?

Anyone who logs in after player 1 logged out and back in can see the cube. The players who are still in the game, 2 & 3 don't see the cube, but player 1 sees it and all new comers see it.



tl;dr


How do I make it so when you destroy something, it stays destroyed for everyone until the server puts it back?

Comments

  • SubZeroGaming
    Options
    Nobody can help? :(
  • vadim
    Options
    Hi,

    The cube is scene object owned by master client. You need to ask master client via RPC to destroy object with PhotonNetwork.Destroy() call. This single call destroys instances of cube on all clients.
  • SubZeroGaming
    Options
    Thank you so much!! That worked :)

    Can you explain why this works? I was original using normal Destroy in an RPC function, and even when using Targets.AllBufferedviaServer meaning it's sent from server, it still stopped working after the main person who destroyed it left the party.


    Either way, i'm happy it works now :) Thank you!
  • vadim
    Options
    This works because this is how objects should be handled in PUN. The owner destroys them with single call. For scene objects the owner is master. For other objects the owner is the one who created them.