Quantcast
Channel: Photon Unity Networking (PUN) — Photon Engine
Viewing all 8947 articles
Browse latest View live

Photon Network instantiate problem when Master changes

$
0
0
Hi, I'm using PhotonNetwork with Unity v2018.3.10f1. I've created a "waiting room" to wait for the players to join a room before starting the game. It works perfectly, the player is instantiated on every player that is already in the room, but when the Master Client leaves the room and rejoins it, is not working anymore and the player is not instantiated on any of the Photon players. The players that are still in the room are instantiated correctly on the new player scene. Is it because the Master Client is lost? (Can't be because its reasigned to other player in the room) How can I do to call the RPC method that instantiate the new player when the Master changes? Code:
public void OnSceneFinishedLoading(Scene scene, LoadSceneMode mode)
 {
      if (PV == null)
      {
           PV = GetComponent();
      }
         
      if (PhotonNetwork.IsMasterClient)
      {
           Debug.Log("Creating lobbyPlayer");
           PV.RPC("RPC_CreateLobbyPlayer", RpcTarget.AllBuffered);
      }
 }
         
 [PunRPC]
 private void RPC_CreateLobbyPlayer()
 {
      PhotonNetwork.Instantiate(lobbyPlayerPrefab, Vector3.zero, Quaternion.identity, 0);
 }
Thanks!

Missing Teleport() or Reset() function in PhotonTransformView

$
0
0
Hi, In PhotonTransformView, m_StoredPosition is set to the transform position in Awake() only. If we teleport the object somewhere else (which we do in our game since we reuse a pool of GameObjects), m_StoredPosition is not reset to a correct value, and the next time there is a synchronization the direction will be computed using a wrong position, and thus the extrapolation on the receiving side will be wrong. Adding this Reset() function to PhotonTransformView and calling it after the teleport fixed the weird movements issue we had:

public void Reset()
{
	m_StoredPosition = transform.position;
	m_NetworkPosition = transform.position;
	m_NetworkRotation = transform.rotation;
}
Could you consider adding a similar function? Or maybe there is already another solution to this problem and I haven't found it? Thanks.

PUN does notconnecring to Master when i use Mobile Internet (Android)

$
0
0
When i use wifi everythink works, but when i turn off wifi and turn on mobile internet it stops working.

Photon on windows x86 and x64

$
0
0
When i tried to test my game(PUN2) on different devices( Win7 x86 and Win10 x64), and my game failed. So i tried to test Demo project and again, nothing worked.(Im using photon free Pun server) Does PUN2 support x86 and x64 at the same time?

Received OnSerialization for view ID xxxx. We have no such PhotonView...

$
0
0
Hallo Photon Forum, for some reason all the serialization events hit my players BEFORE all views even get registered... I would be really greatful if someone has some hints about this issue! This happens only when joining a game that is in progress... Greetings Jasper :)

How to use PhotonNetwork.Instantiate with Object Data

$
0
0
public static GameObject Instantiate(string prefabName, Vector3 position, Quaternion rotation, int group, object[] data)

How can I use this to also contains the custom data for PhotonObject?
I created my bullet which contains PhotonView and I need to set some properties of my bullet so it is sync with all the clients. How can I get the data back from other client? It's quite easy to get the data for RPC calls but I have no idea of how can I set custom data with Instantiate.. :)

I really appreciate for any helps..

Room not creating in Unity with photon 2 when player logged in through playfab

$
0
0
I'm working on a multiplayer game with Unity+photon2+playfab I'm using playfab for login and storing data of player,but since I have connected my photon game with playfab I'm unable to create rooms for matchmaking through email and password Authentication I even saw Demo Hub puncockpit scene offered by Unity Asset Store only to find out that they are using get photonAuthentication token with customID login,but as soon as I change it to some other Authentication login, it doesn't create rooms with error that connected to GameServer waiting for callbacks OnjoinLobby or OnConnectedToMaster and sometimes connected to MasterServer waiting for callbacks OnjoinLobby or OnConnectedToMaster, so is there any way to get photon authentication token with email and username authentication and start matchmaking by creating rooms?

Received an error : Unity version 2019.1.4f : Using PUN2

$
0
0
NullReferenceException: Object reference not set to an instance of an object Photon.Pun.PhotonNetwork..cctor () (at Assets/Photon/PhotonUnityNetworking/Code/PhotonNetwork.cs:989) Rethrow as TypeInitializationException: The type initializer for 'Photon.Pun.PhotonNetwork' threw an exception. Photon.Pun.PhotonEditor.OnUpdate () (at Assets/Photon/PhotonUnityNetworking/Code/Editor/PhotonEditor.cs:200) UnityEditor.EditorApplication.Internal_CallUpdateFunctions () (at C:/buildslave/unity/build/Editor/Mono/EditorApplication.cs:200)

Custom properties removed after the master client leaves the room? (PUN 2.12)

$
0
0
Hello, I've had a problem for months related to custom room properties. I have a couple properties that are set to be listed in the lobby, but after the master client leaves the room, it seems they are deleted (they do not show up in the RoomInfo of the room list sent by the lobby). Here's how I create the room:

		const string ROOM_PROPERTY_GAMEMODE = "g";
		const string ROOM_PROPERTY_PLATFORM = "p";

		RoomOptions roomOptions = new RoomOptions();
		roomOptions.CustomRoomProperties = new ExitGames.Client.Photon.Hashtable();
		roomOptions.CustomRoomProperties.Add(ROOM_PROPERTY_GAMEMODE, gameMode);
		roomOptions.CustomRoomProperties.Add(ROOM_PROPERTY_PLATFORM, platform);
		roomOptions.CustomRoomPropertiesForLobby = new string[] { ROOM_PROPERTY_GAMEMODE, ROOM_PROPERTY_PLATFORM };
		roomOptions.IsOpen = true;
		roomOptions.IsVisible = true;
		roomOptions.MaxPlayers = 8;
		roomOptions.PlayerTtl = 0;
		roomOptions.SuppressRoomEvents = false;
		roomOptions.CleanupCacheOnLeave = false;
		PhotonNetwork.CreateRoom("test", roomOptions))
(gameMode and platform are both enums.) And when parsing the RoomInfo list in OnRoomListUpdate(), I check:

if (!photonRoomInfo.CustomProperties.ContainsKey(ROOM_PROPERTY_GAMEMODE))
{
	// error...
}
Is this a bug in PUN or do I need to do something differently? I'm using PUN 2.12.

[Solved] Creates the object twice

$
0
0
Hello,
I have something strange which I can't fix that :(
First of all, I create the Player object and after there in the his script (For example Player Controller) I want to create for his "Player Canvas" object.

What I did (In the script PlayerController which on the Player):
[code2=csharp]private void Start()
{
GameObject pCanvas = PhotonNetwork.Instantiate("Player Canvas", Vector3.zero, Quaternion.identity, 0);

playerCanvas = pCanvas.GetComponent<PlayerCanvas>();
playerCanvas.Initiate(gameObject.transform, pView.owner.name);

if (pView.isMine)
pCanvas.transform.GetChild(0).GetComponent<ChatBallon>().ActiveChatInputField();
}[/code2]

The problem is when I'm as master joined to the room, all works fine. But, When the client is connects to the room, I see two more objects.
I want to see only one object which have "Player1_UI (The Player Canvas object)" for every Player.

What happens in the scene (objects): "Master, Master_UI", "Client, Client_UI", and more two objects "Player Canvas(Clone), Player Canvas(Clone)".
For example what I want to will happen in the scene (objects): "Master, Master_UI", "Client, Client_UI", Without these two objects ("Player Canvas(Clone)").

When the master is alone:
291fdir.png
And when the client connects:
14mrkom.png

What I did wrong?

I hope you understand me.
Thanks! :)

Dynamic scene loading

$
0
0
Hey, is it possible to have multiplayer game which consists of multiple scenes, where player moves from one scene to another without any loading screens through a transition area in the middle. While walking accross the transition area the old area is removed from the memory and new one is loaded during a transition area? I can get this to work in single player, but can this be done in multiplayer using photon in unity?

Many PhotonViews only for RPC - bad idea?

$
0
0
I know that many PhotonViews are bad, But how about having a lot of PhotonViews with empty observed components, only for RPCs? is that bad for the performance? My intention is to have many PhotonViews on all Helpers for my god prefab, only for RPCs. I could put all the [PunRPC] callbacks on the god prefab script but that would obscure the code

Controlling many separate objects on field with takeover

$
0
0
I want to make a scene with many objects that will be moving and each player will be able to take it, drop it and to some stuff with it. Still I did encounter some difficulties.
For now i'm creating new objects and attach scripts with photonTransformViewClassic. It works fine while I move items carefully wihout interruptions from other players.
This items have ability to group relatively to each other. And I encounter problem with syncing their positions when they are grouping to one parent.
Idea is that unreliable on change update will prevent many info updates if there will be more than 500 objects on scene. And also grouped objects stop syncing separately and new PhotonTransform will be handling group. But when I turning off sync of an object it teleports to not expected locations to one of the player.
May be I miss something. May be I should use better way.
Players transfer ownership by requesting each other to get controll over each object too btw. I also wanted to make something like neutral owner, but it seems like it's not a thing cause one player have to be an owner for info syncing. Any help will be appreciated :#

A question about syncing seats

$
0
0
Hi good people of the photon community! I am implementing a lobby inside a room with 4 seats, and I need each player that joins that room, to have information about the free seats so he can sit there.. Some points: * Each new joined player needs to know the first free seat, instantiate there, and set it as taken.. * Each new joined player must know the location and parent of each player in the room The main question is what will hold all the information about the 4 seats, and their availability? Thank you !

How Client received same time about server?

$
0
0
Hello, we make a mobile game with Photon Cloud ( actually use Pun Classic ) similar to Auto Chess ! so, we load battle Scene 2 client get same time ! but another mobile cpu, ram .. etc another time we wanna check the time in phton how can i sync time between two client ? it seems to one player use another app and back game that's no execute in client code using another app i use unity engnie thank you

Am I supposed to keep checking PhotonView objects != null

$
0
0
When an object is instantiated by Photon and "photonView.isMine" is false, I keep a reference to it and use it to keep track of them in-game.
MainGame mainGameObject;

Awake()
{
  if(photonView.isMine)
  {
     mainGameObject.opponent = this;
  }
}

Update()
{
  if(mainGameObject.opponent != null)  // is this correct?
  {
      // point camera at opponent, get vector to opponent, etc.
  }
}
I think this is a simple question. Am I supposed to check for any references of objects that have a PhotonView attached for != null before acting on them? I have them sprinkled all throughout the code, so I just want to make sure I'm doing things the "Photon" way. (Sorry about the formatting, code tags didn't seem to work well) Thanks!

Players suddenly disappear without any error

$
0
0
my game is a Third-person shooting game, pvp. i can sure the disappear player's gameobject does not be destroyed, but other players just can't see it , and every functions are working normally. thank you very much

Help with syncing parent

$
0
0
I need helping with syncing the object to its parent. I first create it using PhotonNetwork.Instantiate and assign its parent using transform.SetParent. This works but when a new player join, for that player the object isn't parented and is just sitting in the middle. Anyone know how I can sync the object to its parent even for new player.

What could have happened?

$
0
0
I'm learning and made a simple project on 3/15. It instantiates a cube as a player after connecting to room. It worked and every new instance of the .exe I launch, I see another cube. Having learned it, I went to integrate PUN2 to my actual game. It also worked but a few days ago, all of a sudden I don't see other players any more. Debugging shows every instance thinks itself as the master client. After not making progress debugging further the past few days, I remembered the sample project's exe I built 3/15. So I go back to launch it and it also doesn't show other players any more. The last modifed date of this .exe is 3/15, meaning I didn't change anything to cause this behavior. Could my account have somehow changed?

transform.position += Vector2 doesn't look right on other clients?

$
0
0
Hi, I'm adding a dash ability to my game and it feels really nice, I'm basically just adding a Vector2 to my players position for a fixed amount of time. The problem is, while the player moves perfectly on my client, other players won't see me "dash", more just move a little bit upward. It's not like the players are going out of sync, and I believe the problem is how the player lerps on other clients. How can I get the same behaviour on other clients?
Viewing all 8947 articles
Browse latest View live