• 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 /
This post has been wikified, any user with enough reputation can edit it.
avatar image
0
Question by OpenSky · Mar 24, 2014 at 07:31 PM · c#androidbugphoton

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!

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

0 Replies

· Add your reply
  • Sort: 

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.

Welcome to Unity Answers

If you’re new to Unity Answers, please check our User Guide to help you navigate through our website and refer to our FAQ for more information.

Before posting, make sure to check out our Knowledge Base for commonly asked Unity questions.

Check our Moderator Guidelines if you’re a new moderator and want to work together in an effort to improve Unity Answers and support our users.

Follow this Question

Answers Answers and Comments

20 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

Related Questions

Multiplayer: Why dont things move for both players C# 1 Answer

Using swig to generate a C# wrapper from C++ 0 Answers

Probuilder throws ArgumentNullException when Extruding ProBuilder object on Android 0 Answers

Video Player preparing too long Android 0 Answers

Touch Not Working 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