The Photon Forum
is Closed Permanently.

After many dedicated years of service, we have made the decision to retire our Forum and switch to read-only: we´ve saved the best to last! Your search result can be found below. Plus, we offer support via these channels:

Try Our

Please check if you can find an answer in our extensive documentation on PUN.

Join Us
on Discord

Meet and talk to our staff and the entire Photon-Community via Discord.

Stack Overflow

Find more information on Stack Overflow (for Circle members only).

Write Us
an E-Mail

Feel free to send your question directly to our developers.

Item pickup

2015-01-06 20:54:25

Hi, I'm making a FPS game and I am having problems with making weapon pickups. I am network-instantiating the weapon and when the player tosses the weapon on his local machine, the other players synchronises the pos and rot. If it wasn't a weapon I could just instantiate another instance of the it on the machine of the player who picks it up but because it is a weapon I'll need the properties of my weapon script component(i.e. the ammo count) etc. Is there a way to transfer ownership or maybe make the exact same duplicate of the weapon with the same data? Or at least some way to solve this?


2015-01-06 22:43:50

If you are network instantiating the weapons, when the player picks it up is the point where the RPC should be sent to all clients, saying, "hey Player X just picked up this gun" and include any properties of the gun you want to pass, and spawn the gun on that player on all the clients. Any ammo check should technically be done locally to the gun owner, before a Fire RPC, that way each of the "other" players on each client won't even need to keep track of ammo individually.

That's my take anyway.

2015-01-07 15:54:52

Thanks for replying. Actually, I was trying to avoid this method because there're too many properties to be transferred but I think it is the only workaround

2015-01-08 16:22:33

The PUN package includes a demo "Pickup, Score and Teams". You should check out how we solve that case there. It also shows a deterministic way for the pickup (if more than one user tries to pickup the same weapon).

2021-11-04 18:39:37

Are there any PUN2 demos for handling pickup items, something equivalent to the Pickup, Teams, Score demo mentioned above?

Back to top