Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 14 Next capture
2021 2022 2023
2 captures
12 Jun 22 - 14 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 Nodgorod · Sep 08, 2016 at 07:08 PM · instantiatemultiplayerphoton

I am using Photon my game player object does not appear in the scene

I am trying to create a Demo scene where basically there is a sphere game object with the name "SferaMortii". Through input from keyboard, that object only moves around. That is all it has to do and I am trying to make a multiplayer version in order for me to get used to Photon.

I have followed a tutorial that told me to attach a PhotonView Script to the player prefab, I have made a Resources Folder and inside I have moved the prefab, I have made a NetworkManager scrpt where I described the room options,etc. and then I used the Photon.Instantiate function.

I have followed all the steps and when running the game, the object doesn't instantiate and moreover I get this error:

SwitchToProtocol: Udp PhotonNetwork.connected: False UnityEngine.Debug:Log(Object) PhotonNetwork:SwitchToProtocol(ConnectionProtocol) (at Assets/Photon Unity Networking/Plugins/PhotonNetwork/PhotonNetwork.cs:1172) PhotonNetwork:ConnectUsingSettings(String) (at Assets/Photon Unity Networking/Plugins/PhotonNetwork/PhotonNetwork.cs:1219) NetworkManager:Start() (at Assets/Scripts/Network/NetworkManager.cs:12)

My script for the NetworkManager is the following:

using UnityEngine; using System.Collections;

public class NetworkManager : MonoBehaviour {

 const string VERSION="v0.0.1";
 public string roomName="MyRoom";
 public string playerPrefabName="SferaMortii";
 public Transform spawnPoint;

 void Start () {
     PhotonNetwork.ConnectUsingSettings (VERSION);
 }
 


 void OnJoinedLobby()
 {
     RoomOptions roomOptions = new RoomOptions (){ IsVisible = false, MaxPlayers = 4 };
     PhotonNetwork.JoinOrCreateRoom (roomName, roomOptions, TypedLobby.Default);

     PhotonNetwork.Instantiate (playerPrefabName, 
         spawnPoint.position,
         spawnPoint.rotation,
         0);
 }

 void OnJoinedRoom()
 {
     PhotonNetwork.Instantiate (playerPrefabName, 
         spawnPoint.position,
         spawnPoint.rotation,
         0);
 }

}

Should you have any useful advice or any observations, please help troubleshoot the problem!

Comment
Add comment · Show 1
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 AlucardJay · Sep 08, 2016 at 09:27 PM 0
Share

remove line 16: you don't network instantiate in a lobby, only when you have connected to a room. The only purpose of the lobby is to find a room to join, or to create a room.

1 Reply

· Add your reply
  • Sort: 
avatar image
1

Answer by ChristianSimon · Sep 12, 2016 at 08:12 AM

Hi Nodgorod,

please make sure, that OnJoinedLobby() and OnJoinedRoom() are called during connection process. If they are not called, you might set PhotonNetwork.autoJoinLobby = true; at the beginning of your Start() function or check the 'Auto-Join Lobby' option in the PhotonServerSettings file. Otherwise you need to join the lobby manually.

remove line 16: you don't network instantiate in a lobby, only when you have connected to a room. The only purpose of the lobby is to find a room to join, or to create a room.

Please take a look at that, too.

Comment
Add comment · 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

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

5 People are following this question.

avatar image avatar image avatar image avatar image avatar image

Related Questions

[Photon] Looking for example code for late joining clients syncing instantiated game objects that don't exist in the base scene 0 Answers

how to sync audio in instantiated object so all players can hear it? 0 Answers

Photon- block instantiating problem 1 Answer

How to add a component to a prefab 1 Answer

Photon Networking Instantiating Problem 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