Player won't spawn with PUN

Options
I am new to this, so sorry if i am leaving out info or i sound like a noob.

Hello, recently i have been following "https://www.youtube.com/watch?v=v9m48nhfgvI" this tutorial pretty much exactly however i am using the built in Unity FPSController. After following the tutorial, i was met with a few problems. Bearing in mind i have no errors that are popping up, but when i click play nothing happens at no so no player spawns, which i found really weird. I tried to tick the box "AutoJoin Lobby" I heard that helped in some cases but for me it didn't and I have been having this issue for a while now. Any help what so ever will be greatly appreciated. Thanks for your time.

This is the script i used, but again apparently there is no errors.

using UnityEngine;
using System.Collections;

public class NetworkManager : MonoBehaviour {
const string VERSION = "v0.0.1";
public string roomName = "VVR";
public string playerPrefabName = "FPSController";
public Transform spawnPoint;

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

void OnjoinedLobby() {
RoomOptions roomOptions = new RoomOptions() { isVisible = false, maxPlayers = 4 };
PhotonNetwork.JoinOrCreateRoom(roomName, roomOptions, TypedLobby.Default);

}



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






I also created 2 empty's one for a spawn point and one for a network manager which i assigned this script too and then i assigned the spawn point transform to it too.

Comments

  • I am new to this, so sorry if i am leaving out info or i sound like a noob.

    Hello, recently i have been following "https://www.youtube.com/watch?v=v9m48nhfgvI" this tutorial pretty much exactly however i am using the built in Unity FPSController. After following the tutorial, i was met with a few problems. Bearing in mind i have no errors that are popping up, but when i click play nothing happens at no so no player spawns, which i found really weird. I tried to tick the box "AutoJoin Lobby" I heard that helped in some cases but for me it didn't and I have been having this issue for a while now. Any help what so ever will be greatly appreciated. Thanks for your time.

    This is the script i used, but again apparently there is no errors.

    using UnityEngine;
    using System.Collections;

    public class NetworkManager : MonoBehaviour {
    const string VERSION = "v0.0.1";
    public string roomName = "VVR";
    public string playerPrefabName = "FPSController";
    public Transform spawnPoint;

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

    void OnjoinedLobby() {
    RoomOptions roomOptions = new RoomOptions() { isVisible = false, maxPlayers = 4 };
    PhotonNetwork.JoinOrCreateRoom(roomName, roomOptions, TypedLobby.Default);

    }



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






    I also created 2 empty's one for a spawn point and one for a network manager which i assigned this script too and then i assigned the spawn point transform to it too.

    ALSO I FORGOT TO SAY: I added a cylinder to the FPSController so player should be able to each other but they can't.
  • Tobias
    Options
    I don't see why the code does not run (maybe it's not added to some object in the hierarchy?!).

    It makes sense to debug your code.
    In doubt, just place Debug.Log calls in your code to make sure it's being called as expected. Check what happens versus your expectation.

    We have more tutorials on our doc page. Maybe you start with PUN by doing one of those one by one, actually coding them (without modification)...
    See:
    https://doc.photonengine.com/en-us/pun/current/tutorials/pun-basics-tutorial/intro
    And:
    https://doc.photonengine.com/en-us/pun/current/tutorials/tutorial-marco-polo
  • Tobias said:

    I don't see why the code does not run (maybe it's not added to some object in the hierarchy?!).

    It makes sense to debug your code.
    In doubt, just place Debug.Log calls in your code to make sure it's being called as expected. Check what happens versus your expectation.

    We have more tutorials on our doc page. Maybe you start with PUN by doing one of those one by one, actually coding them (without modification)...
    See:
    https://doc.photonengine.com/en-us/pun/current/tutorials/pun-basics-tutorial/intro
    And:
    https://doc.photonengine.com/en-us/pun/current/tutorials/tutorial-marco-polo

    Thank you very much for your response. I've doubled checked everything and I do not see a problem in the hierarchy. Also how would i do the debugging thing?