Jump to content
This site uses cookies! Learn More

This site uses cookies!

armedunity.com uses cookies to improve user experience.

By continuing to use this site, you agree to allow us to store cookies on your computer.

  • 0
Sign in to follow this  
omard2000

Why is Photon player being instantiated twice?

Question

Hi Everyone,

 

I have a really quick question. The script is working except it instantiates the player twice and I cannot figure out why.

Here is the outline of the script:

1) Waits until enough players join

2) Once enough players have joined a countdown from 5 seconds starts

3) All players are joined into a new multiplayer scene

 

I can't figure out why double of every player are being instantiated.

 

Thanks!

 

Here is my script:

 

Please login or register to see this code.

 

Share this post


Link to post
Share on other sites

7 answers to this question

Recommended Posts


  • 0

Check in the scene and see if there is 2 objects in the scene with this script attached in play mode ( not in edit mode). Your code looks ok so I’m guessing with dontdestroyonload, somehow or someway 2 of the same scene objects are ending up in the same scene 

Share this post


Link to post
Share on other sites
  • 0

@OcularCash I checked and there is only 1 object in the scene in both edit and play mode with the script attached to it. Do you think it could be the OnEnable or OnDisable functions?

Share this post


Link to post
Share on other sites
  • 0

I have no idea. I’ve never used either so not sure when they’re called. But that “is” something that could double the calls. Wait, what’s up with the addcallbacktarget being called in both enable and disable?

Share this post


Link to post
Share on other sites
  • 0

Maybe you instantiate a first as non-local, and another as local?

Share this post


Link to post
Share on other sites
  • 0
Please login or register to see this quote.

Hmm... but how would the user control the player and how would I send RPC calls? Shouldn't there only be one player per user?

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Answer this question...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Sign in to follow this  

×
×
  • Create New...