Hello everyone! I don't know if PUN supports data preservation. For example, I built a house on the ground. When the server restarted, I could read the archive and brush out the house.Can PUN be realized?
↧
Can PUN be used as a network like Rust?
↧
NetworkCullingHandler for scene gameobjects
Hello, I think the main purpose of the CullingArea is to use NetworkCullingHandler in the player, but what about the common gameobjects with AI that runs in the master and should be sync with the rest of clients? , can we do a modification of the NetworkCullingHandler script to check if there is any player near so it will sync position,rotation,animation (through Photon Tranform and Animation Views components) and other things only when there are players around a cluster of the culling area?
Thanks!
↧
↧
Is there any way to leave out a search parameter, or have PUN ignore a custom room property? (PUN 2)
I would like to move away from finding and creating rooms by a name, and want to be able to find a room by properties- Game Mode, Player starting health, Pickups active, etc. But am a bit lost. I looked at the "Matchmaking Guide" and I don't understand how it works well enough. If I want to "not care" about starting player health, for example. How do I search for rooms with only the properties that I want, and disregard what they have for other properties that I don't care about.
↧
Connecting to Master Server works in build but not editor.
Iv experience this issue several time once in unity 2018.1 and 2018.2.
the editor will work for a period of time then after maybe 2 - 3 hours working, it no longer connects to the master.
I then build the game and the built version works and is able to connect. any ideas or suggestions would be greatly appreciated.
Have tried.
- Fresh install
- Host
- New Project
- Different Versions of unity
- restarting router/Modem
- Restarting pc
- Restarting Unity
↧
Unity, event runs twice, can't figure out why.
Hello guys, i'm making a Real-Time multiplayer combat game, but i'm stuck with a thing:
When i am in the room, i disconnect from the room and i reconnect back again, my event, OnLevelFinishedLoading runs twice, but i've added an condition for prevent spawn prefab on the lobby, but it spawn twice of them in the game scene. There's my script:
private void Awake () {
DontDestroyOnLoad (this.transform);
if (FindObjectsOfType (GetType ()).Length > 1) {
Destroy (gameObject);
}
PhotonNetwork.sendRate = 50;
PhotonNetwork.sendRateOnSerialize = 40;
SceneManager.sceneLoaded += OnSceneFinishedLoading;
}
private void Update () {
int rand = Random.Range (0, SpawnPoints.Length);
spawnPointSpawn = SpawnPoints[rand].transform.position;
if (Input.GetKeyDown (KeyCode.Escape)) {
// pHandler.despawnPlayer();
// PhotonNetwork.DestroyPlayerObjects (PhotonNetwork.player);
PhotonNetwork.LeaveRoom (becomeInactive: false);
}
}
public void createNewRoom () {
if (PhotonNetwork.connectedAndReady) {
PhotonNetwork.CreateRoom (photonB.createRoomInput.text, new RoomOptions () { MaxPlayers = 10 }, null);
} else {
Debug.Log ("Connessione non riuscita perche' lenta, riconnettendo..");
PhotonNetwork.Reconnect ();
}
}
public void joinOrCreateRoom () {
if (PhotonNetwork.connectedAndReady) {
RoomOptions roomOptions = new RoomOptions ();
roomOptions.MaxPlayers = 10;
PhotonNetwork.JoinOrCreateRoom (photonB.joinRoomInput.text, roomOptions, TypedLobby.Default);
} else {
Debug.Log ("Connessione non riuscita perche' lenta, riconnettendo..");
try { PhotonNetwork.Disconnect (); } catch { Debug.Log ("Non posso disconnettermi, perche' non sono collegato -->"); }
try { PhotonNetwork.Reconnect (); } catch { Debug.Log ("Non posso riconnettermi, perche' sono gia connesso: --> Riavvia il gioco"); } //(pConnectSettings.versionName);
}
}
public void cambialivello () {
SceneManager.LoadScene ("GameRemake");
}
public void OnJoinedRoom () {
cambialivello ();
Debug.Log ("Ti sei connesso alla stanza!");
}
public void OnLeftRoom () {
SceneManager.LoadScene ("Main");
Debug.Log ("Uscito dalla stanza");
}
public int listagiocatorinm;
public void OnSceneFinishedLoading (Scene scene, LoadSceneMode mode) {
if (scene.name == "GameRemake") {
spawnPlayer();
foreach (PhotonPlayer pl in PhotonNetwork.playerList) {
listagiocatorinm++;
}
Debug.Log (listagiocatorinm);
presence.partySize = listagiocatorinm;
presence.partyMax = 10;
presence.state = string.Format ("Playing");
presence.details = string.Format ("Fighting..");
isJoined = true;
InvokeRepeating ("updateRpcDiscordInterno", 0.0f, 15.0f);
}
}
void updateRpcDiscordInterno () {
DiscordRpc.UpdatePresence (ref presence);
}
private void spawnPlayer () {
//PhotonNetwork.Instantiate (Player.name, spawnPointSpawn, Quaternion.identity, 0);
var clone = PhotonNetwork.Instantiate (Player.name, spawnPointSpawn, Quaternion.identity, 0);
clone.name = "Player" + Random.Range(1, 400);
Debug.Log ("Spawnato il player");
}
A help would be grateful :smile:
↧
↧
Error using custom authentication with playfab. Need help!
I get this error when trying to use custom authentication with playfab:
OperationResponse 230: ReturnCode: 32755 (Custom authentication service error: Error). Parameters: {} Server: NameServer Address: ns.exitgames.com:5058
CODE;
private void AuthenticateWithPhoton(GetPhotonAuthenticationTokenResult result)
{
var playFabPhotonToken = result.PhotonCustomAuthenticationToken;
Debug.Log("Photon token acquired." + playFabPhotonToken);
PhotonNetwork.AuthValues = new AuthenticationValues();
PhotonNetwork.AuthValues.AuthType = CustomAuthenticationType.Custom;
PhotonNetwork.AuthValues.AddAuthParameter("username", cacheUserId);
PhotonNetwork.AuthValues.AddAuthParameter("token", playFabPhotonToken);
PhotonNetwork.ConnectUsingSettings();
}
↧
Live video stream
Hi,
Currently I try to implement a live video transmission using the RaiseEvent functionality of PUN and the Photon Cloud. Here is a sample snippet code:
textureToSend.SetPixels(webCamTexture.GetPixels());
var bytes = textureToSend.EncodeToJPG(50);
byte evCode = 0;
RaiseEventOptions raiseEventOptions = new RaiseEventOptions { Receivers = ReceiverGroup.Others };
SendOptions sendOptions = new SendOptions { Reliability = false };
PhotonNetwork.RaiseEvent(evCode, bytes, raiseEventOptions, SendOptions.SendUnreliable);
The encodeToJPG results in a 16kb array in my case. Sending 10-15 frames per second would therefore produce ~200kb of data p/s. Unfortunately, my application always disconnects from the room after sending the first few frames. Is this due to the amount of data? If so, are there any known optimization tweaks?
↧
Enable Unity's Ui only for the player how triggered it
Hello.
I am having quite a hard time trying to find a solution to my problem.
I am trying to activate a panel with Unity's new UI, but this panel to be active only on the screen of the player who triggered it and not to the others. I am trying to use photonView.isMine but it is not behaving as it should. the problem for this is that if I trigger the panel on a view that is not mine, it shows the panel only on my view, so this is not what I need. I need the panel to be shown only on the screen of the player who triggered it.
Your help would be much appreciated.
Thanks!
↧
Pun 2 Mobile
Hi dear my friends,
I want to know how I make 2D Mobile Game with PUN 2. I have not found 2D Mobile tutorial. How I make a joystick and where I add codes? I have found PUN1 tutorials but PUN1 and PUN2 are different.
Thank you
↧
↧
Room always showing 0 players
Client A creates a room, client B joins, OnPlayerEnteredRoom is called but the number of players always shows 0. I've tried PhotonNetwork.PlayerList.Length.
I should note when client A OnJoinedRoom is called PhotonNetwork.InRoom is returning false even though the state is joined.
↧
Multiple packet loss
Good day!
In our application there are a lot of disconnections of players and within 2 to 4 seconds messages may not come at all. We tested on various types of network connections (TCP and UDP), at various points of Wi-fi and used different regions (RU, EU, US) the result is absolutely the same. It repeats when there are more than 2 players in a room.
What can be done with this problem?
↧
PUN replacing dots with commas when passing a string trough OnSerializeView
Im really lost on this one, This didn't start to happen until recently, out of the blue. It messed up my whole project and its unplayable. I use strings with all the info needed and then decompose them in the OnSerializeView, in order to pass transform position, rotation and other properties.
Recenlt yand out of the blue, it started replacing dots on my string by commas on transfer, or directly changing the values oddly. I can't understand this since I don't pass any float, vector or anything. ITs all strings and it all worked perfectly during a long time. I don't know what to do any more, since the string I pass on "stream.iswriting" is alright, but the one that "stream.isreading" returns is messed up, as I said, with many dots replaced by commas, so there goes all my vector, float and double parsing. I have Unity 2018 and the latest version of Unity Classic.
I am completely lost on this one.
↧
1 PUN for 2 different projects UNITY
Hi all,
Well ive been working in a "launcher" project made with Unity that allows the client to create and invite other players to a room. Now in a different unity project with the same app id im trying to join that room. Is that posible? Room was created in one and cannot connect in another.
- Same app id version.
- Same pun version.
- Same game version.
thanks,
↧
↧
MP Scoreboards?
I hope I am using the right title. In my game, I want a scoreboard displayed for each player connected to the room. This will display their score and username to each other player. I had a version of this working before but removed the code by mistake and now I can not figure out how I had it working before. Here is what it looks like:
https://puu.sh/BXfUa/3701e3b8a9.jpg
I want this UI to be created for each player that joins the room and is view-able to all others. Each player will have their own. This UI will also get destroyed when the player leaves. ATM I have it instantiated when the player joins but it only works for the master client and if you were in the room before a player joined. Meaning, if you joined first, you will see yours and every other ui. If you join second, you will only see yours and those who joined after you. Also, it doesn't display their players name and score.
↧
PUN 2 Not Working
I'm developing a game with Unity and I´'m using Photon's PUN 2 To manage the game's online mode, before, the online connect and list the rooms of the lobby very well, but, I don't know why it isn't working now. Now I can't joina room by searching it with JoinRoom(RoomName) or JoinRandomRoom(), it just searches a room, then, marks the current state to "Joining" and goes back to the lobby. Also, need to tell that the rooms in lobby aren´t listing, even waiting 5 miutes or more in a room. Here's my code, thanks:
private Button B;
private Text T;
private AudioSource Audio;
public AudioClip OK, Fail;
void Start ()
{
GameObject.Find("StartPanel").GetComponent().SetBool("Show", true);
Audio = GetComponent();
B = GetComponent
The list rooms code:
public GameObject roomPrefab;
public Sprite Four, Two, Three;
private string RoomName;
private int PlayerAmount;
private int MaxPlayers;
private Image I;
private Vector2 RoomVector;
private bool Lock = false;
public GameObject Content;
private List RoomList;
private bool IsntNull = false;
private Dictionary cachedRoomList;
private Dictionary roomListEntries;
private Dictionary playerListEntries;
private GameObject Handle;
public RooManager instance;
private void Awake()
{
if (instance != null)
{
DestroyImmediate(gameObject);
return;
}
DontDestroyOnLoad(gameObject);
instance = this;
cachedRoomList = new Dictionary();
roomListEntries = new Dictionary();
}
void Start()
{
//Content = GameObject.Find("Content").GetComponent();
RoomVector = new Vector2(450 /*370 */, this.transform.position.y);
}
private void ClearRoomListView()
{
foreach (GameObject entry in roomListEntries.Values)
{
Destroy(entry.gameObject);
}
roomListEntries.Clear();
}
public override void OnJoinedRoom()
{
if (playerListEntries == null)
{
playerListEntries = new Dictionary();
}
foreach (Player p in PhotonNetwork.PlayerList)
{
GameObject entry = Instantiate(roomPrefab);
playerListEntries.Add(p.ActorNumber, entry);
}
}
public override void OnLeftRoom()
{
foreach (GameObject entry in playerListEntries.Values)
{
Destroy(entry.gameObject);
}
playerListEntries.Clear();
playerListEntries = null;
}
public override void OnLeftLobby()
{
cachedRoomList.Clear();
ClearRoomListView();
}
private void Update()
{
print(PhotonNetwork.NetworkClientState);
}
private void UpdateRoomListView()
{
foreach (RoomInfo Item in cachedRoomList.Values)
{
RoomName = Item.Name;
PlayerAmount = Item.PlayerCount;
MaxPlayers = Item.MaxPlayers;
RoomVector.y -= 100;
GameObject RoomPrefab = Instantiate(roomPrefab, RoomVector, transform.rotation) as GameObject;
RoomPrefab.transform.Find("RoomName").GetComponent().text = RoomName;
if (Item.Name.Length == 10)
{
Vector2 AddFive = new Vector2(RoomPrefab.transform.Find("RoomName").transform.position.x + 10, RoomPrefab.transform.Find("RoomName").transform.position.y);
RoomPrefab.transform.Find("RoomName").transform.position = AddFive;
}
if (Item.Name.Length >= 10)
{
Vector2 AddTen = new Vector2(RoomPrefab.transform.Find("RoomName").transform.position.x + 40, RoomPrefab.transform.Find("RoomName").transform.position.y + 20);
RoomPrefab.transform.Find("RoomName").transform.position = AddTen;
RoomPrefab.transform.Find("PlayerInt").GetComponent().fontSize = 47;
}
RoomPrefab.transform.Find("PlayerInt").GetComponent().text = PlayerAmount.ToString();
if (Item.MaxPlayers == 4)
{
RoomPrefab.transform.Find("IPlayerA").GetComponent().sprite = Four;
}
else if (Item.MaxPlayers == 2)
{
RoomPrefab.transform.Find("IPlayerA").GetComponent().sprite = Two;
}
else if (Item.MaxPlayers == 3)
{
RoomPrefab.transform.Find("IPlayerA").GetComponent().sprite = Three;
}
RoomPrefab.transform.SetParent(Content.transform);
}
}
public override void OnRoomListUpdate(List roomList)
{
ClearRoomListView();
UpdateCachedRoomList(roomList);
UpdateRoomListView();
print("Updated");
}
private void UpdateCachedRoomList(List roomList)
{
foreach (RoomInfo info in roomList)
{
// Remove room from cached room list if it got closed, became invisible or was marked as removed
if (!info.IsOpen || !info.IsVisible || info.RemovedFromList)
{
if (cachedRoomList.ContainsKey(info.Name))
{
cachedRoomList.Remove(info.Name);
}
continue;
}
// Update cached room info
if (cachedRoomList.ContainsKey(info.Name))
{
cachedRoomList[info.Name] = info;
}
// Add new room info to cache
else
{
cachedRoomList.Add(info.Name, info);
}
}
}
}
Need to say that in the list rooms code, the "Update" message yes prints, and theres no errors or warnings in the console.
Add comment
↧
Stuck on ConnectingToNameServer. App placed in background does not reconnect to master server.
I'm running into a problem where the app goes into the background and disconnects. When I refocus I check if we are disconnected and reconnect. The problem is that it only reconnects tot the nameserver and not the master server. When I try to connect I cannot because PeerState is not Disconnected.
PhotonNetwork.networkingPeer.PeerState == Connected
PhotonNetwork.connected == false
PhotonNetwork.connectionStateDetailed == ConnectedToNameServer
↧
See knock back effect immediately on client side
Hello guys ! Currently I'm working on client side prediction of my game. I want a client to see knocked back effect on target immediately when the target gets hit by rocket. Using photon.instantiate (on master client) can achieve this , but there is a latency from player pressing shoot button to seeing the rocket projectile coming out. So I wonder if I can use client side prediction to achieve this. I've tried to move the target immediately when the client predicts hit, however due to serializing position , it just moves back and forth. Or what is the usual way to do for online games that client attack has effects on target position?
↧
↧
How to update a gameobject and all its children on network?
I'm making a bubble shooter game. So far, I have achieved that both the player are instantiated rightly with a single problem -- the bubble which were supposed to be instantiated only on one client, are instantiated on both. Secondly, the new balls that are created, need to be in relevant Player's hierarchy, but I have seen they don't go to it ( they remain parent free). So I want to ask two things... 1) how to make balls to be instantiated only in its own view 2) how to make newly created balls to be a child of its Player. Thanks in advance
↧
Photon and Unity 2018.2.2
Hi, I got this error when I tried to update Unity to 2018.2.2.
Updating Assets/Photon Unity Networking/Editor/PhotonNetwork/Views/PhotonAnimatorViewEditor.cs - GUID: a3f61bade114730459f7ad45f5f292c1...
Invalid #ifdef expression: UNITY_5 || UNITY_5_0 || UNITY_5_3_OR_NEWER (error around
↧
PUN2 with no Internet connection cause errors
Good day, guys.
I have the problem. When i use
PhotonNetwork.ConnectUsingSettings();
with disabled Internet connection it causes 2 errors which i can't handle (try-catch doesn't work too):
Connect() to 'ns.exitgames.com' () failed: System.Net.Sockets.SocketException: Этот хост неизвестен.
at System.Net.Dns.GetHostByName (System.String hostName) [0x00000] in :0
at System.Net.Dns.GetHostEntry (System.String hostNameOrAddress) [0x00000] in :0
at ExitGames.Client.Photon.IPhotonSocket.GetIpAddress (System.String address) [0x00015] in C:\Dev\photon-sdk-dotnet\PhotonDotnet\IPhotonSocket.cs:270
at ExitGames.Client.Photon.SocketUdp.DnsAndConnect () [0x00004] in C:\Dev\photon-sdk-dotnet\PhotonDotnet\SocketUdp.cs:148
UnityEngine.Debug:LogError(Object)
Photon.Realtime.LoadBalancingClient:DebugReturn(DebugLevel, String) (at Assets/Photon/PhotonRealtime/Code/LoadBalancingClient.cs:1819)
ExitGames.Client.Photon.SocketUdp:DnsAndConnect() (at C:/Dev/photon-sdk-dotnet/PhotonDotnet/SocketUdp.cs:192
and
InvalidOperationException: EnsureRunningOnMainThread can only be called from the main thread
UnityEngine.Object.EnsureRunningOnMainThread () (at C:/buildslave/unity/build/Runtime/Export/UnityEngineObject.bindings.cs:153)
UnityEngine.Object.GetInstanceID () (at C:/buildslave/unity/build/Runtime/Export/UnityEngineObject.bindings.cs:73)
UnityEngine.Object.IsNativeObjectAlive (UnityEngine.Object o) (at C:/buildslave/unity/build/Runtime/Export/UnityEngineObject.bindings.cs:182)
UnityEngine.Object.CompareBaseObjects (UnityEngine.Object lhs, UnityEngine.Object rhs) (at C:/buildslave/unity/build/Runtime/Export/UnityEngineObject.bindings.cs:140)
UnityEngine.Object.op_Inequality (UnityEngine.Object x, UnityEngine.Object y) (at C:/buildslave/unity/build/Runtime/Export/UnityEngineObject.bindings.cs:403)
UnityEditor.AudioMixerWindow.OnPauseOrPlayModeStateChanged () (at C:/buildslave/unity/build/Editor/Mono/Audio/Mixer/GUI/AudioMixerWindow.cs:313)
UnityEditor.AudioMixerWindow.OnPauseStateChanged (PauseState state) (at C:/buildslave/unity/build/Editor/Mono/Audio/Mixer/GUI/AudioMixerWindow.cs:302)
UnityEditor.EditorApplication.Internal_PauseStateChanged (PauseState state) (at C:/buildslave/unity/build/Editor/Mono/EditorApplication.cs:282)
UnityEngine.Debug:LogError(Object)
Photon.Realtime.LoadBalancingClient:DebugReturn(DebugLevel, String) (at Assets/Photon/PhotonRealtime/Code/LoadBalancingClient.cs:1819)
ExitGames.Client.Photon.SocketUdp:DnsAndConnect() (at C:/Dev/photon-sdk-dotnet/PhotonDotnet/SocketUdp.cs:192)
Tested in Unity Editor 2018.2.14f1 on Windows 10 x64.
OnDisconnected()
is not called.
How can i handle the case when a user doesn't have internet connection in PUN2?
Sorry, i'm a newbie in network stuff.
↧