Playmaker Forum

PlayMaker Help & Tips => PlayMaker Help => Topic started by: Bjakuja on January 22, 2014, 08:52:24 PM

Title: Photon Destroy [SOLVED]
Post by: Bjakuja on January 22, 2014, 08:52:24 PM
Hi! Since we are working on one great multiplayer game we use Photon and ofc Playmaker but right now I am stuck with destroy function.
Here is the example of what I want to destroy:
I have my inventory which works just great for multiplayer and after drop item from inventory (it's synced to other players, they see it at proper position and rotation) to the scene I can pick it back ofc, but I want other players to pick that item as well because this will be use for loot after you kill somebody. Thing is that other players can actually pick that item and store in inventory but I can't destroy that item from network, item is set to be destroyed after someone pick it and GUI item will be added to inventory. Only player who drop that item can actually destroy it but I want to destroy it with other players, actually players who pick that item I want to destroy it.

So my question here is how can I actually destroy objects in photon network if I am not master client? IS there any way to get master client and do this:

" get master client and store it/ get game object you want to destroy and use set fsm game object to set game object you want to destroy in master client/ send event to master client to destroy that object"

So how actually I can destroy something that is network instantiated?
IF I use photon network destroy it will destroy item but only on owner player scene, not on other players scenes even if item has photon view component because only master client can destroy network item. Tried everything and don't have idea how to do this.
This is also important for me because I want to know how I actually spawn items on multiplayer scene like weapons, medpacks, ammo after some time visible by everyone and pickable by everyone.... and who picks certain item, that player should destroy that item.

Any idea how to solve those problems?
Thanks and Cheers!
Title: Re: Photon Destroy
Post by: jeanfabre on January 23, 2014, 07:13:25 AM

 Through this gameobject, broadcast an RPC event to itself, each instance will receive it, each instance will check if it is the owner, and only when it is the owner then destroy it.


Title: Re: Photon Destroy
Post by: Bjakuja on January 23, 2014, 08:24:18 AM
Thanks Jean, I will try that solution but I have a question about this, isn't that broadcast event to every object a huge impact for server and network for example if I have 50 players in same room?

Also tell me is this good approach, get owner properties of certain item so I get owner of that item and then send RPC event to only that owner to network destroy that item?

And it turns out that items on scene are actually under the Owner "Scene" so scene owns those items, so is that mean that I have to send event to scene to network destroy items?

What do you think about this?
Title: Re: Photon Destroy
Post by: Bjakuja on January 23, 2014, 09:59:42 AM
Tried your solution and it's working for items that are instantiated over network,
but how can actually destroy scene items, when I use this method it will throw this error:
"Failed to 'network-remove' GameObject. Client is neither owner nor masterClient taking over for owner who left: View (0)1003 on CubeTest(Clone)"

What should I do, should I use some scene items check by it like compare id if is't bellow 1000 it's scene item and just use normal destroy gameobject or? Because if I do so item will be destroyed by the player who destroyed it but for other players item will remain there because it's not network instantiated.

Any solution?
Title: Re: Photon Destroy
Post by: Bjakuja on January 23, 2014, 10:32:16 AM
Yeah it works now with get ID, just instead of network destroy I destroy gameobject with same RPC method but only will send different event for example will not sent destroy network item I will send destroy scene item.

Thanks a lot Jean, that small post explained everything and now my inventory works completely fine with multiplayer  ;D

I will mark this thread as SOLVED

Title: Re: Photon Destroy [SOLVED]
Post by: jeanfabre on January 24, 2014, 06:34:30 AM

 Cool, I am glad you have made progress.