Item pickup
The whole answer can be found below.
Try Our
Documentation
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.
Read More on
Stack Overflow
Find more information on Stack Overflow (for Circle members only).
Item pickup
SlonCHL
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?
Comments
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.
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
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).
Are there any PUN2 demos for handling pickup items, something equivalent to the Pickup, Teams, Score demo mentioned above?
Back to top