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

Spawn object and enemies npc

$
0
0
Hi everyone I have a problem with the object and npc spawning.
I'm trying using a PunRPC method SpawnChest() and only the Master Client could spawn this object, but when other players join in match other chests will spawn...
Every chest has a trigger collider and when a player triggers the area, a defined number of npc will spawn in the area.
So I thought that when a player trigger the area, this player send to Master Client a PunRPC to invoke the npc's spawning.
Sorry for the english, but I'm so confused....

Does FindFriends only work when not in a room?

$
0
0
I have FindFriends working when I am not in a room, and I call it periodically to get the online status of friends. Works fine before I join a room.

However when I create/join a private (IsVisible = false) room, it doesn't work anymore. I would like to invite friends to the private room once I'm already in it. I get these two errors instead:

Operation failed: OperationResponse 222: ReturnCode: -2 (Unknown operation code). Parameters: {} Server: GameServer
UnityEngine.Debug:LogError(Object)
NetworkingPeer:OnOperationResponse(OperationResponse) (at Assets/Photon Unity Networking/Plugins/PhotonNetwork/NetworkingPeer.cs:1544)
ExitGames.Client.Photon.PeerBase:DeserializeMessageAndCallback(Byte[])
ExitGames.Client.Photon.EnetPeer:DispatchIncomingCommands()
ExitGames.Client.Photon.PhotonPeer:DispatchIncomingCommands()
PhotonHandler:Update() (at Assets/Photon Unity Networking/Plugins/PhotonNetwork/PhotonHandler.cs:157)

FindFriends failed to apply the result, as a required value wasn't provided or the friend list length differed from result.
UnityEngine.Debug:LogError(Object)
NetworkingPeer:OnOperationResponse(OperationResponse) (at Assets/Photon Unity Networking/Plugins/PhotonNetwork/NetworkingPeer.cs:1922)

In NetworkingPeer line 1906, both lists are empty:
i.e. onlineList and roomList are both null.

What happen if the number of users exceed the CCU?

$
0
0
I'm using photon cloud with 100 maximum CCU. Because I have no chance to reach that maximum number, I'm wandering what happen if there are more users than the restriction of CCU connect to the server.

Thank you!

Cheaters new exploits

$
0
0
So theres been a modder going around in my servers crashing peoples games
I don't know what he does but whenever he "closes" a room you can still see it in the list, but if you try to join you get this exception before right after OnJoinedRoomFail() is called: https://pastebin.com/pe22bEyH
after that you get the OnPhotonJoinedRoomFailed(), OnLeftLobby() and OnDisconnectedFromPhoton() logs.
http://i.imgur.com/aTNAoWj.png

Just what is this?

Joinrandomroom issue

$
0
0
My game has a multiplayer mode. I use the joinRandomRoom function to create or join room. My room maximum
player count is 2. If A player and B player press the joinRandomRoom button in the same time. They cannot search any player. How can I search player if press the button in the same time

Frined Invitation from Photon cloud or server

$
0
0
Hello
in my game when i create a room with maximum player 6 than i wan to invite a player who is already on photon server or photon cloud. Not facebook friend is there any way to retrieve connected player in lobby not in room and i can add this player in my friend list so i can play game with this friends. i know without Enter in room we cant get the details about the player and its also available in room only. but i have to do some task which i have mentioned. please suggest me any plugin or any other method.

Thank you.

playfab ccu

Custom room props: Custom objects ok?

$
0
0
Sure I can make "G" for Game Mode and have a string with the name of the mode, or something simple like "isSomething" that's a bool.

....can I use a custom class object?

class x {
string somethingStr = "this is it";
bool somethingBool = true;
};

lobby chat

$
0
0
Hello!

Is it possible to be in a room and still receive room list updates? (for a lobby with a chat)

What approaches are possible here?

thanks,
Slav

Network.LoadLevel() not working (urgent)

$
0
0
I'm currently trying to program transitions between games. Once a game ends, a RPC is sent out to tell all clients to re-enter my "match lobby" menu while still in the level that ended. (I'm completely re-using the match lobby menu from the main menu, and just throwing it in at the end of the game)

When the masterclient hits a "start match" button it calls Network.LoadLevel(), the same way it does when starting a match from the main menu. However, only the masterclient's level loads--the others stay frozen in the last scene and only see various state updates. In other words, "OnLevelWasLoaded()" is never triggered on the other client's games.

Any ideas why this might happen? I've also noticed some warnings from Photon on the masterclient's side, like receiving OnSerialization for nonexistent views.

I'm close to a deadline, so would I be able to work around this temporarily by doing manual level loading? (by sending out an rpc to load a level and pausing the message queue)
    [RPC]
    void EndGame(string conclusionString)
    {
        conclusion = conclusionString;
        GameObject.FindGameObjectWithTag("HUD").GetComponentInChildren<MenuManagerScript>().GoToMenu((int)HUDMenuScript.MenuName.LOBBY);
    }

void Update()
{
//...
            //check for end of game
            if (timeLimit > 0 && ((Time.time - (float)room.customProperties["st"]) > timeLimit))
            {
                room.SetCustomProperties(new Hashtable { { "on", false } });
                PhotonNetwork.RemoveAllBufferedMessages();
                PhotonNetwork.RemoveAllInstantiatedObjects();
                photonView.RPC("EndGame", PhotonTargets.All, "The game has ended...");
            }
//...
}

//elsewhere
void OnGUI()
{
if (PhotonNetwork.isMasterClient)
        {
            if(GUI.Button(new Rect(50, Screen.height - 120, 90, 70), "Start Match"))
            {
                PhotonNetwork.room.SetCustomProperties(new Hashtable { { "st", Time.time } });
                PhotonNetwork.LoadLevel("blahblahblahPlaygroundScene");
            }
}
}

Thanks!
-Scott

How to change player timeout from 10 sec (that unity automatically sets) to 2 sec

$
0
0
HI,
There need to be 2 things done by unity:
a. if master client is not able to send a package then on master client switch that packet should be resend by the new master client automatically
b. allow users to set player time to live for a room as we want that player gets disconnected from photon within 2 sec of no response and photon does it after 10 sec

Unable to call an RPC with two integer parameters

$
0
0
Hey there guys,

I'm having the issue stated in the title. The console is logging the error:

Operation failed: OperationResponse 225: ReturnCode: 32760 (No match found). Parameters: {}
UnityEngine.Debug:LogWarning(Object)

It works when I pass two strings, however it will not work if I pass two integers. Here is the code:

public void SpawnToAvailablePoint(PhotonView horsePhotonView)
{
for (int i = 0; i < totalSpawnPoints; i++)
{
if (!spawnPoints[i].Occupied)
{
photonView.RPC("SetPointToOccupied", PhotonTargets.AllBuffered, i, horsePhotonView.viewID);
return;
}
}
Debug.LogWarning("NO MORE SPAWN POINTS!!!");
}

[PunRPC]
public void SetPointToOccupied(int index, int viewID)
{
PhotonView.Find(viewID).transform.position = spawnPoints[index].transform.position;
spawnPoints[index].Occupied = true;
}

I'd love to know what the problem is. I'm stuck on this at work!

Thanks!

Can I turn off multiplayer for my game?

$
0
0
Hello. I'm making a Game on PUN. For example, I made beta version and send it to my friends, they will test it. But can I in one moment turn off connection to server for these old versions?

(Also additive question: what is difference between pun, bolt and thunder?)

Spawnable enmies in multiplayer game

$
0
0
I am spawning 10-20 enemies in my game. How do i do this. Should enemies need to be attached with photonview.
Is this method efficient??

"UNITY_XBOXONE builds have to use a special Photon library with Native Datagram Encryption."

$
0
0
I'm getting the following Error when I connect in Xbox One:

"UNITY_XBOXONE builds have to use a special Photon library with Native Datagram Encryption. This is missing. Check your build setup!"

Also,

"UNITY_XBOXONE builds must use AuthValues.AuthType \"CustomAuthenticationType.XboxCheck\". Set this before calling any Connect method."

I think the second one is fixed, but where in the world do I find a special photon library with native datagram encryption?

Thanks!

[Pun] Cross Platform issue

$
0
0
Hello,
I implemented PUN for a game I am working on and while testing I noticed that i can't connect Unity Editor(running on a
laptop with windows) to a client running on Android Phone.
Tested some more and can play on 2 Android devices or on 2 PC's( Editor + windows build) but i can't make the game created on a PC be visible on the Android Phone.

Is this how it should work? If not, any ideas on what is happening?

Ty.

Better way to sync 2d Top-Side tanks?

$
0
0
Here is my game screenshot. Which way better to synchronize these tanks? I use Photon Transform View with Sync Position Lerp 7 and Sync Rotation Lerp 7. I think it syncing a bit slow, about 0.3-0.4s delay I think. Are there other ways to sync?

OnPhotonSerializeView is never called issue

$
0
0
Hallo,

I try to use a PhotonView, but the OnPhotonSerializeView is never called.
The Class I use is called DrawController and is a Component of Prefab DrawCanvas
I searched and found a lot of similar issues, but I checked all the things I could find:

1. The script I use does use Photon. MonoBehavior


2. I drew the Script component on the PhotonView Observed Component directly from the GameObject itself


3. I implemented the Method in the Script


4. The Prefab is located in Resources Folder


5. I Instantiate it via the Photon.Instantiate method


6. I always test with 2 other players with the same build
7. Logging in to the room, instantiating the Object etc., all works fine, I can see it on all clients
8. I tested stand-alone and WebGL
9. I tested with all three Observe options (I still don't get what would trigger "on change")

Still the Method was not called once (I would see the Debug.Log("Test Serialize View!"); )

I could not find anything else, that could cause the issue... Do I miss something?

Best regards
Mario

A Question About OpRaiseEvent and OnEvent

$
0
0
version ; Photon-Server-SDK_v3-4-31-10808
//--------------------------------------------------OpRaiseEvent Code-----------------------------
if (GUI.Button(new Rect(Screen.width / 2 + 150, 200, 50, 30), "Send"))//SendMsg
{
Hashtable chatContent = new Hashtable {{cvEvent.Key.ChatMsg, chatMsg}};
peer.OpRaiseEvent((byte) cvEvent.Code.Chat, chatContent,true);
}
//--------------------------------------------------OnEvent Code-----------------------------------------

public void OnEvent(EventData eventData)
{
Debug.Log("触发了事件:" + eventData.ToStringFull());

string username; //接收到的用户名
int userId; //接收到的用户的编号
userId = (int) eventData.Parameters[LiteEventKey.ActorNr];
switch (eventData.Code)
{
case (byte) cvEvent.Code.Chat:
Hashtable customEventContent = eventData.Parameters[LiteEventKey.Data] as Hashtable;
string chatMsg = customEventContent[(byte)cvEvent.Key.ChatMsg].ToString();
msg = userDic[userId] + ":" + chatMsg;
break;
}
Debug.Log(msg);
}
//---------------------------------------------------------------------------------------------------------------
I want to build a chat room .but some user can't get the msg;
for example :



1.user1 enter room ;
2.user2 enter room;
3.user3 enter room;
4.user3 send msg ,user 1 and user 2 both receive the msg.
5.user2 send msg , user 1 can receive the msg,but user 3 cant ;
6.user1 send msg , user 2 and user3 cant receive the mag;

Can U tell me what is wrong? thank U so much!!


//----------------------------------------------------Full Code ---------------------------------------------------------


using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using ExitGames.Client.Photon;
using ExitGames.Client.Photon.Lite;
using System;


public class GameClient : MonoBehaviour,IPhotonPeerListener {
public void DebugReturn(DebugLevel level, string message)
{
Debug.Log("Level:"+level+ " Msg:" + message);
}//debug

public void OnStatusChanged(StatusCode statusCode)
{
switch (statusCode)
{
case StatusCode.Connect:
Debug.Log("Connect Succuse");
break;
case StatusCode.Disconnect:
Debug.Log("DisConnect/Connect Fail ");
break;
case StatusCode.Exception://异常
Debug.Log("Connect Error");
break;
}
}//连接状态改变

public void OnEvent(EventData eventData)
{
Debug.Log("触发了事件:" + eventData.ToStringFull());

string username; //接收到的用户名
int userId; //接收到的用户的编号
userId = (int) eventData.Parameters[LiteEventKey.ActorNr]; //获取用户ID
switch (eventData.Code)
{
case LiteEventCode.Join:
if (!userDic.ContainsKey(userId)) //如果不存在用户ID
{
username =
((Hashtable) eventData.Parameters[LiteEventKey.ActorProperties])[(byte) cvEvent.Key.UserName]
.ToString(); //获取用户名
userDic.Add(userId, username); //加入到玩家字典
msg = "玩家编号为:" + userId + "的玩家:" + userDic[userId] + "进入房间";
}
else
{
msg = "已存在玩家编号为" + userId + "的用户,名字为:" + userDic[userId];
}
break;
case LiteEventCode.Leave:
msg = "玩家编号为:" + userId + "的玩家:" + userDic[userId] + "离开房间";
userDic.Remove(userId); //移除玩家字典里的玩家信息
break;
case LiteEventCode.PropertiesChanged:
break;
case (byte) cvEvent.Code.Chat:
Hashtable customEventContent = eventData.Parameters[LiteEventKey.Data] as Hashtable;
string chatMsg = customEventContent[(byte)cvEvent.Key.ChatMsg].ToString();
if (userDic.ContainsKey(userId)) //如果存在用户ID
{
msg = userDic[userId] + ":" + chatMsg;
}
break;
default:
break;
}
Debug.Log(msg);
} //响应事件

public void OnOperationResponse(OperationResponse operationResponse) //接受服务器返回信息
{
switch (operationResponse.OperationCode)
{
case LiteOpCode.Join:
int playerId = (int)operationResponse.Parameters[LiteOpKey.ActorNr];
Debug.Log("玩家编号为:" + playerId + "进入房间");
break;
case LiteOpCode.Leave:
Debug.Log("玩家退出房间");
break;
default:
ExcuteMsg(operationResponse);//执行游戏指令信息
break;
}
}

void ExcuteMsg(OperationResponse operationResponse)//执行游戏指令信息
{

}



private LitePeer peer;
private string myName= "Input name";//玩家名
private string msg = "";//输出显示事件信息
private string chatMsg = "";//聊天信息
private byte channel = 0;
private int[] userIdList;
private Dictionary userDic=new Dictionary();//用于存放用户编号和名字

public bool isBroadCast=true;
// Use this for initialization
void Start ()
{
peer=new LitePeer(this,ConnectionProtocol.Udp);//,端口5055要和服务器配置文件的端口一样
peer.Connect("127.0.0.1:5055", "Lite");//连接服务器的

}

// Update is called once per frame
void Update ()
{
peer.Service();//监听端口获取数据;
}

void SendMsg2Server(OperationRequest operationRequest)
{
// Debug.Log(operationRequest.Parameters.ContainsKey(LiteOpKey.GameId));
//Debug.Log(operationRequest.OperationCode);
peer.OpCustom(operationRequest, true, channel, false);//可信信道发送请求到服务器;

}


void OnGUI()
{
myName = GUI.TextField(new Rect(Screen.width / 2 - 50, 15, 100, 30), myName); //输入姓名

GUI.Label(new Rect(Screen.width / 2 - 50, 150, 400, 50), msg); //显示信息

chatMsg = GUI.TextField(new Rect(Screen.width / 2 - 150, 200, 300, 30), chatMsg); //聊天框

if (GUI.Button(new Rect(Screen.width / 2 + 150, 200, 50, 30), "Send"))//发送聊天框内容
{
Hashtable chatContent = new Hashtable {{cvEvent.Key.ChatMsg, chatMsg}};
if (chatMsg=="")
{
return;
}

peer.OpRaiseEvent((byte) cvEvent.Code.Chat, chatContent,true);

msg = myName + ":" + chatMsg;
chatMsg = "";
}


if (GUI.Button(new Rect(Screen.width / 2 - 50, 50, 100, 30), "EnterRoom"))
{
#region 简化前 用PhotonPeer

// OperationRequest operationRequest = new OperationRequest {OperationCode = LiteOpCode.Join};
// Dictionary para = new Dictionary {{LiteOpKey.GameId, "1"}};
//operationRequest.Parameters = para;
// SendMsg2Server(operationRequest);


#endregion

//简化后用LitePeer
Hashtable gameProperties = new Hashtable(), actorProperties = new Hashtable();
actorProperties.Add((byte) cvEvent.Key.UserName, myName);
peer.OpJoin("游戏名字/房间名字", gameProperties, actorProperties, isBroadCast /*是否广播玩家属性*/);
}


if (GUI.Button(new Rect(Screen.width / 2 - 50, 100, 100, 30), "LeaveRoom"))
{
peer.OpLeave();

}
}



}

Server list with ping and list of servers on all the regions

$
0
0


So... can you help me to create a ping that a user can visualize to choose the right server? Beacuse I also need your help to create a list of servers of all the regions to choose the server you want (bith best ping). Thank you guys <3
Viewing all 8947 articles
Browse latest View live


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