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

How to create a squad/party system and join a game together?

$
0
0
We're introducing a new squad/party feature to our game and are having trouble conceptualizing how to do matchmaking with groups of players. The new mode will have teams of 2 to start, with up to 10 teams joining a game. My current idea for how to implement this is as follows:
  1. Join both players to a special, private room with a max player count of 2.
  2. Have the party leader begin a search for a true game room, stating that they'll need 2 opens spots and passing the other player as an "expected player."
  3. One the party leader finds the room, communicate the room code to the other player so that they may join as well.

However, the issues that I think are present with this solution are:
  • When players are joined to a room they can't actively search for other rooms since they're connected to the game server, not the master server
  • Once the leader joins the actual game room they'd lose any method of quickly informing their group mate of what room to join (No RPC or changing of Room Properties since they're no longer in the same room)

Are these issues true? Any ideas about how to navigate around them? I know you can do outside-of-room communication between players using Photon Chat but ideally we're trying to stick with just PUN. Thanks for any help!

Assign Player Index (GetRoomIndex) Utility Script

$
0
0
Hello!
I am having a dilemma where I don't know how to assign each player there own index number. To call the PlayerRoomIndexing script I am successfully using the namespace 'using Exitgames.UtilityScipts' which is working fine and in my update function for my player's script I am calling ' playerIndex = PlayerRoomIndexing.instance.GetRoomIndex(photonView.owner);' I don't know if this is right but this was the closest thing I found online. I want to be able to give each player their own index number and then reference that number in another script to be able to link it to a scoreboard. I would be grateful for some help.
-Eli

PUN Basics Tutorial - repositioning player after leaving the room doesn't work

$
0
0
Hi.
I think I've spotted an error when following the Basic PUN tutorial. I also verified that this problem exists when running the completed demo from Demos folder.

I'm starting two games, one in the Unity's window, one as an executable after building it. I join the same room, two players spawn. I move the player IN THE UNITY WINDOW to the edge of the arena. Now, when I leave the room from the executable game, the player in the Unity window is not repositioned to the (0,5,0) position above the arena and just falls down infinitely.
I first thought that it might be a problem with animator and root motion. However, what is really strange is that when I do it in a reverse manner, moving the player in the executable to the edge of the arena and leaving the room in the Unity window, it seems that the player is repositioned correctly, which leads me to the conclusion that it might be something with the position synchronization?

Thanks!

How can i share list between two players?

$
0
0
I am trying to make turn based like chess but rpg elements each player has several characters. I wrote list1 and list2 to hold each player characters. But while each player has own lists. So there is 4 list.Thus, i cant set player action. How can i solve this problem?

How to save persistent player data to a 3rd party service?

$
0
0
Hello, I'm setting up my multiplayer game with Photon. I'm looking to save persistent player data (like skill rating) to an external data storage (like a database), but it's something I've never done and not sure how to do. Is it possible? If so, how would you recommend I do that? Thank you.

Other player can't move through the first player..!!

$
0
0
Help me,

My game is puck sling...parent had photonview component and child is pucks(5 puck) thi is my photon prefab. when initiating both players and 1st player sling puck at that momement when touch to 2nd player's puck (logic is also 2nd puck sling due to force of 1st player's puck) but not happening may be ownership issue but now i m confuse what i do for ownship and all.

Laggy changing slider value

$
0
0
Hello guys.I have two scripts.First it is trigger when player get bool isRepair = true.If player exit trigger isRepair = false.In second script i change value slider.
Second script:
void Update(){
if(isRepair){
GeneratorSlider.value += 4 * Time.deltaTime;
photonView.RPC("ActivateGen", RpcTarget.AllBuffered, GeneratorSlider.value);
}
}
[PUNRPC]
void ActivateGen(float s){
GeneratorSlider.value = s;
}
PLEASE HELP ME.WHY SLIDER VALUE SYNC VERY LAGGY

Photon client server can't able to perform action

$
0
0

I have made a board game using photon but only master server 's move is showing


Expanding 999 limit for PhotonView.

$
0
0
I have much more then 1 thousand game object at single room, but photonView Max ID is only allow index of 999. I want to expand that limit.
Is that possible? And if "yes", what restrictions it will have or what kind of a problems it will create?

Maybe its also possible to add PhotonView component at runtime, to let interacting objects synchronize theirs values, when its necessary?

Thank you.

Rooms, Unity Scenes and PUN

$
0
0
I've a map (a unity scene), from which players can choose a particular area, each area will be online multiplayer (like GTA Online), in these areas people can run around and see other players too. From within these areas players can choose to play particular games (likes Chess, for eg), where there will be a match making and the game will start. How I go about making this? Currently, I have a "Launcher" GameObject in my scene. So when the map scene loads the scene makes connection with the Photon Server and get gets it connected. Then, when a player clicks on a area, lets say Area A, I FindOrCreate a room with the same name and then load the Area A scene using Photon. But the problem I'm facing is, is whenever a new player joins the room a brand new scene gets created for all the players who are already in the scene, and then every one gets teleported back to 0,0,0 (the spawn location), and all the character meshes collide and its a human fireworks. What am I doing wrong?

PUN2 with no Internet connection cause errors

$
0
0
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.

Need help to enable/disable buttons for players.

$
0
0
Hi. I have a requirement where I will have 5 players connected to the same room. And when it is the first player turn the UI button should be enabled only to him and it should be disabled to all other players and after the first player click the button it will get disabled and for the 2nd player alone it should be enabled and so on to all other players. I tried but it only works for the first player every time. Any tutorial if available will help me. Thanks

[HELP] Storing PlayerInfo (Score, Health)

$
0
0
Hi guys, Im experienced with Unity but this is my first time trying out networking.
I have made a menu and can connect, spawn and move both of the players individually. I've been stuck for a couple of days now trying to store the data for the player. For example I want them to be able to have a score and display both of the scores with player names on both of the screens . What's the best way of doing this ?
Any help is appreciated

Player Components being Disabled by photon

$
0
0
Hi, I have an issue where all my local players components are disabled on the root object.


I parent my player to another photon object (owned by another player e.g a vehicle), when said object is Destroyed my player has all of its components disabled on the root object and i cant figure out why this is. we are using Photon V1 as well. I tested doing this (Enter Vehicle, player parents to photon spawned object owned by another player) then i manually removed player from the Hirarchy parent, on account B i disconnected and player was fine so its fairly safe to assume its coming from this.

player A is parented to player B vehicle, player b disconnects and their vehicle is destroyed, player A is un parented from player B vehicle and player B vehicle is cleaned up.

Getting a missing reference exception on recreating or rejoining a room

$
0
0
So i'm building a basic card game and i have provided a button using which player can exit the game. The problem is when the other players exit the game as well and create another room to play again all players get a missing reference exception that few objects were destroyed. however those so called destroyed objects are clearly there and visible in the inspector. This is the error

MissingReferenceException: The object of type 'GameObject' has been destroyed but you are still trying to access it.
Your script should either check if it is null or you should not destroy the object.
GameManager.AssignCardsToPlayer (UnityEngine.GameObject player, System.String[] cards) (at Assets/Scripts/GameManager.cs:673)
GameManager.OnEvent (ExitGames.Client.Photon.EventData photonEvent) (at Assets/Scripts/GameManager.cs:805)
Photon.Realtime.LoadBalancingClient.OnEvent (ExitGames.Client.Photon.EventData photonEvent) (at Assets/Photon/PhotonRealtime/Code/LoadBalancingClient.cs:3018)
ExitGames.Client.Photon.PeerBase.DeserializeMessageAndCallback (ExitGames.Client.Photon.StreamBuffer stream) (at <11e9abbca912444aa80ed58a280369fc>:0)
ExitGames.Client.Photon.EnetPeer.DispatchIncomingCommands () (at <11e9abbca912444aa80ed58a280369fc>:0)
ExitGames.Client.Photon.PhotonPeer.DispatchIncomingCommands () (at <11e9abbca912444aa80ed58a280369fc>:0)
Photon.Pun.PhotonHandler.Dispatch () (at Assets/Photon/PhotonUnityNetworking/Code/PhotonHandler.cs:205)
Photon.Pun.PhotonHandler.FixedUpdate () (at Assets/Photon/PhotonUnityNetworking/Code/PhotonHandler.cs:139)

I'm pretty new to photon and i'm guessing it has something to do with the user not properly exiting the room. Am i missing something here? Any help is appreciated.

This is the exit logic on the quit button:
private IEnumerator DisconnectPlayer()
{
PhotonNetwork.Disconnect();
while (PhotonNetwork.IsConnected)
yield return null;
SceneManager.LoadScene(0);
}

This is the logic for connecting to a room (if relevant)
public void JoinRoom()
{
if (PhotonNetwork.IsConnected)
{
ExitGames.Client.Photon.Hashtable expectedCustomRoomProperties = new ExitGames.Client.Photon.Hashtable() { { "bootAmount", bootAmount } };
PhotonNetwork.JoinRandomRoom(expectedCustomRoomProperties,0);
}
}

public override void OnJoinRandomFailed(short returnCode, string message)
{
roomName = "room_" + Guid.NewGuid().ToString();
SetMsg("Joining failed. Creating new room");
RoomOptions options = new RoomOptions();
options.CustomRoomProperties = new ExitGames.Client.Photon.Hashtable() { { "bootAmount", bootAmount } };
options.CustomRoomPropertiesForLobby = new string[] { "bootAmount" };
options.MaxPlayers = 6;
options.PublishUserId = true;
options.CleanupCacheOnLeave = true;
PhotonNetwork.CreateRoom(roomName, options, TypedLobby.Default);
}

Player Custom Properties throws an exception

$
0
0
Hi,

I have implemented the code below, to create new player properties.
var customProperties = new ExitGames.Client.Photon.Hashtable() {{12, "twelve"}};
PhotonNetwork.LocalPlayer.SetCustomProperties(customProperties);

I get this error:

OpSetPropertiesOfActor() failed. actorProperties must not be null nor empty.
UnityEngine.Debug:LogError(Object)
Photon.Realtime.LoadBalancingClient:DebugReturn(DebugLevel, String) (at Assets/Photon/PhotonRealtime/Code/LoadBalancingClient.cs:2304)


Any help please?

Photon lagging on Wi-Fi

$
0
0
Hello,

we develop a VR application in Unity3d and we use Photon PUN 2 for networking.
Whenever we connect our VR pc's via our companys wi-fi we are randomly getting some very nasty lags in network position transmition (cca 0.5s delay). See attached video please: https://streamable.com/f83f9a - lagging starts for instance in 0:15s.
If we connect our pc's via ethernet cable, everything is smooth. Same application, same hardware, same place, just the connection type varies (cable vs wi-fi).
Do you have any idea what problem might we have with our internal network insfrastructure in relation to photon networking? Is this happening to anybody else?

Please also see the attached SupportLogger logs.
cable - https://ibb.co/4RGz9xV
wifi - https://ibb.co/gTNZ7rg

Many thanks for help!

PS: It is not a problem with interpolation, we checked that.

PUN issue with playerlist

$
0
0
@Tobias

I added few bots in the game as players by
PhotonNetwork.CurrentRoom.AddPlayer(bot); //bot is derived from Photon.Realtime.Player

now when the bot loses the game I want to kick him so I am calling
PhotonNetwork.CloseConnection(bot);

but PhotonNetwork.CurrentRoom.Players, PhotonNetwork.PlayerList, PhotonNetwork.CurrentRoom.PlayerCount nothing is being affected I am not able to remove the bots from the game from the master client
So is there a different way to add bots as players since I need to use PUNTurnManager or a way to remove bots from the playerlist?

Instantiating with RPCs

$
0
0
This is my first time using Photon PUN and I am running into a problem that I can't really solve. In my scene, I have three blue canvas and one red canvas. I am trying to instantiate a camera for each of my clients, say three, so that Player 1 sees a blue canvas and Player 2 sees a different blue Canvas and Player 3 will see the red canvas. I've been running it a few times and it seems relatively inconsistent on what each player sees. Sometimes all three players will each get a blue canvas, sometimes two of the three players will get a red canvas etc.

I was wondering where my understanding of RPCs is failing and would like some help to see where my logic fails in the code.
    private void createCamera() {
        for (int i = 0; i < PhotonNetwork.PlayerList.Length; i++) {
            int number = i;
            // the first player in listOfPlayers should see the red Canvas. 
            if (listOfPlayers.Peek().NickName.Equals(PhotonNetwork.PlayerList[i].NickName)) {
                // canvasesXYZ.Length - 1 is the location of the red Canvas (the last in the array)
                number = canvasesXYZ.Length - 1;
            }
            if (PhotonNetwork.PlayerList[i].IsLocal) {
                view.RPC("localCamera", PhotonNetwork.PlayerList[i], number);
            }
        }
    }

    [PunRPC]
    private void localCamera(int number) {
        _playerCamera = Instantiate(playerCamera, canvasesXYZ[number], new Quaternion(0,0,0,0));
    }

The createCamera() is under Awake() and part of the Manager class and the PhotonView view and Manager class is attached to the Manager gameObject. canvasesXYZ stores a Vector3 where the camera should be placed. I've also tried without the if (PhotonNetwork.PlayerList is local and left the RPC call in the for loop.

If it's too difficult to understand, let me know and I will try to explain.

Thanks so much for the help.

Want each client to set a parameter on network object once its created

$
0
0
So our master client creates a network object. There is one parameter in this network object which I want to change for each client depending on the state of that particular client. Initially I tried putting the check in the Start() method but obviously that start method is only run by whoever initially instantiates the network object.

Is there a callback for some other method that every single client will run as soon as it receives notification that a new network object has been created?

I guess alternatively I could try putting something that is run the first time the Update() method is called but that seems really messy. Any advice appreciated. Thanks.
Viewing all 8947 articles
Browse latest View live


<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>