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.

Players spawned double but why?

2021-09-22 07:01:26

Hi there. I reused a piece of code for some testing. But when two players join the game the player prefab model is spawned two times for both of them and i can't figure out why.

This is the Spawn Method:

And here the initialize:

When i run it i see both players with ID 1 and 2


2021-09-22 09:18:41

Why so complicated?

I mean: Are you sure you need a ImInGame RPC? There is a callback when players join. You'd only need an RPC to signal that you are ready and even then, it might be better to use a Custom Player Property (which is a value that gets synced with late joining players).

It also seems like your Initialize can be replaced with OnPhotonInstantiate, which is part of the PhotonNetwork.Instantiate workflow already.

Your RPC sounds as if it's called for any joining player. And for each join, you PhotonNetwork.Instantiate a networked object.

2021-09-22 10:26:30

The players should not join late but start at the same time. But it might be the case that i don't understand you correctly.

The Second Thing is: it seems so but i am not sure about it because i want them to spawn at different locations and i have to set a position for the instantiate workflow and that would spawn all objects at the same place? or just initialize it at one place and spawn it at another?

Don't i have to call it for every player to initialize them? because every player needs to be a networked object with its own prefab.

The objects are not duplicated when i switch the number of spawn points.

2021-09-22 10:45:20

Also i don't know how to use

Correctly. From the example i don't know where to put it.

2021-09-22 11:12:50

so i was a bit confused but put it like this:

it worked But it also broke my camera controller which could not follow the players around anymore.

2021-09-22 14:41:32

You probably want to read the PUN Basics Tutorial and code-along. It handles camera and input setup for multiplayer and how to instantiate.

2021-09-23 06:39:29

Thx Tobias

Seems you are omnipresent here and that there is some hard work right now but i appreciate that you took some time to answer here.

I build my first try with a somewhat outdated tutorial it seems because some things have changed and i have to deep dive into that. Not sure right now if i should stick to Pun ore work with Bolt instead. As far as i understand i can test both products freely and Bolt has some more advanced features while Pun was the first photon product.

As my goal is to have the knowledge and tools for professional Multiplayer based games (but still not the scale where something like quantum is needed) would you recommend bolt over pun?

2021-09-23 13:49:13

In that case, I would recommend Fusion. It's our upcoming networking solution, which works with MonoBehaviours and enables even top notch, competitive multiplayer gaming. It is what happens when a few clever guys (not me) work on networking approaches for a long time.

Both, Bolt and PUN 2, will be around for a while longer as LTS versions but won't get bigger updates anymore.

Back to top