Playmaker Forum

Playmaker Help & Tips => Playmaker Help => Topic started by: jackforyou on June 26, 2016, 09:24:09 PM

Title: How do I destroy game object on Photon network[SOLVED]
Post by: jackforyou on June 26, 2016, 09:24:09 PM
First, I used Photon Network Destroy to destroy game objects. It seemed to be nice, but it could only use to destroy game objects when I am master client. If I am other players try to destroy game objects, it gonna be an error.

After I read this thread http://hutonggames.com/playmakerforum/index.php?topic=6118.msg29592#msg29592 (http://hutonggames.com/playmakerforum/index.php?topic=6118.msg29592#msg29592), I tried to follow this instruction, and I still DO NOT UNDERSTAND.

I used RPC broadcast FSM Event to destroy game objects by setting like this
Photon Target : All
Event Target : Self
Remote Event : Destroy Self (it send to another state that destroy game object scene by using Destroy Self action)
After I did by following this thread, Game objects were destroy in scene, but they still be in Photon network.
What Should I deal with this issue?
Title: Re: How do I destroy game object on Photon network
Post by: jeanfabre on June 26, 2016, 10:25:00 PM
Hi,

 Only the Owner can destroy itself, so when you send an rpc to all on destroying, every instance but the owner should ignore it, and only the owner will proceed with the destruction.

 If your network GameObject is a Scene GameObject, then only the masterClient can destroy it.

http://hutonggames.com/playmakerforum/index.php?topic=6118.0

So, if the owner destroy itself ( when "isMine" is true), then all other instances over the network will be destroyed too automatically by PUN system.

bye,

 Jean
Title: Re: How do I destroy game object on Photon network
Post by: jackforyou on June 27, 2016, 07:20:25 AM
How can I destroy a network GameObject if I'm not a masterClient?
Title: Re: How do I destroy game object on Photon network
Post by: jeanfabre on June 28, 2016, 12:15:39 AM
Hi,

 You can only to destroy a network GameObject when you are the Owner. This means you need to check the "IsMine" and it has to be true, then you can delete this networked GameObject.

 IF you created a scene GameObject ( not owned by any client), then you MUST be in the MasterClient to destroy it.

Bye,

 Jean
Title: Re: How do I destroy game object on Photon network
Post by: jackforyou on June 28, 2016, 03:43:15 AM
Tank you, Jean. It was very clear, so I could have solved this issue already.
And I want to share my solution that I think it can help other people who want to do the same as me.