- Home /
Photon networking doesn't sync
Hello everybody! I write here today, because I have a problem with my Unity game, and specially with Photon Networking. I am making a multiplayer FPS for Android (maybe IOS) using Unity, and for the network, Photon Networking.
My problem is : when i test the game using Bluestacks on Windows and my Nexus 7, I can see the other player connecting, but GUI.Label(new Rect(0, 140, 250, 100), "Total persons : " + PhotonNetwork.countOfPlayers); show me only 1, whereas on the other device it's wrote 2. And when I move the player, he hasn't move on the other device, and vice-versa. However, I have a photon view attached to the prefab, which is observing the prefab. I think I made something wrong, or it's because of player prefab.
My prefab look like that :
PlayerDefaultPrefab
|>player
|>Controls
||>ButtonA
||>ButtonB
||>JoystickCircle
|||>thumbArea
|||>thumbFinger
|>Camera Pivot
||>Main Camera
This is my NetworkManager.cs script:
using UnityEngine;
using System.Collections;
using System.Collections.Generic;
public class NetworkManager : MonoBehaviour {
public Transform script1;
public Transform playerPrefab;
public Camera standByCamera;
SpawnSpot[] spawnSpots;
void Start() {
spawnSpots = GameObject.FindObjectsOfType<SpawnSpot>();
Connect();
}
void SpawnPlayer() {
if(spawnSpots == null) {
Debug.LogError("WTF?!");
return;
}
SpawnSpot mySpawnSpot = spawnSpots[Random.Range(0, spawnSpots.Length)];
//GameObject myPlayerGO = (GameObject)PhotonNetwork.Instantiate("PlayerDefaultPrefab", mySpawnSpot.transform.position, mySpawnSpot.transform.rotation, 0);
GameObject myPlayerGO = (GameObject)PhotonNetwork.Instantiate("PlayerDefaultPrefab", Vector3.zero, Quaternion.identity, 0);
standByCamera.enabled = false;
myPlayerGO.transform.FindChild("Controls").gameObject.SetActive(true);
myPlayerGO.transform.FindChild("Camera Pivot").gameObject.SetActive(true);
((MonoBehaviour)myPlayerGO.transform.FindChild("player").GetComponent("AnimationControllerExt")).enabled = true;
}
void OnGUI() {
GUILayout.Label(PhotonNetwork.connectionStateDetailed.ToString() );
}
void Connect() {
Debug.Log("Works!");
PhotonNetwork.ConnectUsingSettings("Debug");
}
void OnJoinedLobby() {
Debug.Log("JoinedLobby");
PhotonNetwork.JoinRandomRoom();
}
void OnPhotonRandomJoinFailed() {
Debug.Log("JoinFailed");
PhotonNetwork.CreateRoom(null);
}
void OnJoinedRoom() {
Debug.Log("JoinedRoom");
SpawnPlayer();
}
void OnCustomAuthenticationFailed() {
Debug.Log("Error connecting");
}
void OnDisconnectedFromPhoton() {
Debug.Log("Player disconnected :(");
Application.LoadLevel(0);
}
}
If you want some other informations please say it. Also, I am sorry for my english, I am not english ;) I can add some screens. Otherwise, is thare a tutorial for making an Android multiplayer FPS ? Thank you soooo much!
Your answer
Follow this Question
Related Questions
How To Call Health Script From Another Script ? 1 Answer
Multiplayer: client cant see host C# 0 Answers
Android Downloading Packages Online 2 Answers
null texture passed to GUI.DrawTexture 0 Answers
Run Function when user shakes mobile andriod unity c# 0 Answers