Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 13 Next capture
2021 2022 2023
1 capture
13 Jun 22 - 13 Jun 22
sparklines
Close Help
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
avatar image
0
Question by pawan.arora · May 03, 2014 at 07:07 AM · c#networkingmultiplayerphoton

How to instatiate two players simultaneoulsy before loading level

Hi, I'm new in unity networking and I'm using photon server for multiplayer game, and I've two scenes.

In first scene, I want a new player who has joined the room, to wait for another player to join. After total player count equals two I'm loading a new scene, where I'm actually instantiating prefab. But only the last player who has joined the room, actually able to enter in new scene, other player stuck in first scene.

The code in first scene:

 void OnJoinedRoom()
 {
     if (PhotonNetwork.countOfPlayers == 2)
     {
     PhotonNetwork.LoadLevel(1);
     }
 }


Code in second scene:

  void start()
     {
       PhotonNetwork.Instantiate("PlayerPad", Vector3.zero, Quaternion.identity, 0)
      
     }

Does anyone know how can I make possible to enter two more player simultaneouly in new scence, after meeting some condition first. Thanks in advance.

I even asked the same question Here, but couldn't get any reply.

Comment
Add comment
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

1 Reply

· Add your reply
  • Sort: 
avatar image
1
Best Answer

Answer by liortal · May 03, 2014 at 06:19 PM

Your code look just about right: the player who joins the (Photon) room second will observe that countOfPlayers is 2.

When using PhotonNetwork.LoadLevel, you may need to also set PhotonNetwork.automaticallySyncScene to true.

Otherwise, the 2nd player's call to lodd a level will not be synced to let the first player know that he should be loading a level.

See the API documentation here: http://doc-api.exitgames.com/en/realtime/current/pun/doc/class_photon_network.html#a5bb`203a37b6db717583ea7b81fb56852

Comment
Add comment · Show 2 · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image pawan.arora · May 03, 2014 at 07:10 PM 0
Share

Yes. PhotonNetwork.automaticallySyncScene is what needs to be done. Thanks for your help.

avatar image MRxBIGxSTUFF · Jul 22, 2015 at 10:05 PM 0
Share

Where did you implement PhotonNetwork.automaticallySyncScene = true? I tried under PhotonNetwork.LoadLevel(1); and still get the same result with player 2 loading into the game scene and player 1 hanging in the lobby?

Your answer

Hint: You can notify a user about this post by typing @username

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this Question

Answers Answers and Comments

21 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

Photon Cloud, Multiplayer Damage script 0 Answers

Networking - Move all players to a position? (Photon) 1 Answer

Unity Photon Network - Text Mesh Sync 1 Answer

RPC called by OnPhotonPlayerConnected doesn't work 2 Answers

Unity3D Photon movement synchronization 0 Answers


Enterprise
Social Q&A

Social
Subscribe on YouTube social-youtube Follow on LinkedIn social-linkedin Follow on Twitter social-twitter Follow on Facebook social-facebook Follow on Instagram social-instagram

Footer

  • Purchase
    • Products
    • Subscription
    • Asset Store
    • Unity Gear
    • Resellers
  • Education
    • Students
    • Educators
    • Certification
    • Learn
    • Center of Excellence
  • Download
    • Unity
    • Beta Program
  • Unity Labs
    • Labs
    • Publications
  • Resources
    • Learn platform
    • Community
    • Documentation
    • Unity QA
    • FAQ
    • Services Status
    • Connect
  • About Unity
    • About Us
    • Blog
    • Events
    • Careers
    • Contact
    • Press
    • Partners
    • Affiliates
    • Security
Copyright © 2020 Unity Technologies
  • Legal
  • Privacy Policy
  • Cookies
  • Do Not Sell My Personal Information
  • Cookies Settings
"Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges