playMaker

Author Topic: How do I destroy game object on Photon network[SOLVED]  (Read 14601 times)

jackforyou

  • Playmaker Newbie
  • *
  • Posts: 9
How do I destroy game object on Photon network[SOLVED]
« on: June 27, 2016, 12:24:09 AM »
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, 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?
« Last Edit: June 29, 2016, 02:51:54 AM by jeanfabre »

jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 15500
  • Official Playmaker Support
Re: How do I destroy game object on Photon network
« Reply #1 on: June 27, 2016, 01:25:00 AM »
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

jackforyou

  • Playmaker Newbie
  • *
  • Posts: 9
Re: How do I destroy game object on Photon network
« Reply #2 on: June 27, 2016, 10:20:25 AM »
How can I destroy a network GameObject if I'm not a masterClient?

jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 15500
  • Official Playmaker Support
Re: How do I destroy game object on Photon network
« Reply #3 on: June 28, 2016, 03: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

jackforyou

  • Playmaker Newbie
  • *
  • Posts: 9
Re: How do I destroy game object on Photon network
« Reply #4 on: June 28, 2016, 06: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.
« Last Edit: June 28, 2016, 10:06:40 AM by jackforyou »