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

Prefab can not be instantiated over the network.

$
0
0
I have been having this problem for a while and I have failed to solve it. My problem is simple. I have a prefab in my resources folder. I have two clients in a room the master and the non-master client. The master client is the first one to join a room and it has it's prefabs instantiated(a ball, an infield player and a goal keeper). When the second player gets into the room he has to instantiate his own prefabs(same as player one). The problem is the ball only gets instantiated by the master client and the second player doesn't instantiate the ball. Another thing is after running the logic to run the ball the ball variable on the MatchManager script changes from 'None (BallRoot)' to 'Missing BallRoot', which makes me think the ball is being created and then somehow destroyed. The player and the goal keeper gets instantiated successfully on the network by the second client when he joins the room. Here is my logic for instantiating the ball BallRoot = PhotonNetwork.Instantiate(BallDB.Balls[UserControllerData.SelectedBallIndex].name, BallSpawnPoint.position, BallSpawnPoint.rotation, 0) .GetComponent(); I realized that if there is client that has already instantiated the ball then the other client won't be able to instantiate the ball by wrapping the instantiate ball logic inside an 'if client is not master' logical statement like this. if(!PhotonNetwork.isMasterClient) { BallRoot = PhotonNetwork.Instantiate(BallDB.Balls[UserControllerData.SelectedBallIndex].name, BallSpawnPoint.position, BallSpawnPoint.rotation, 0) .GetComponent(); } The ball gets instantiated on the second player and the ball variable on the 'MatchManager' script is set properly. So how do I fix this problem

The type or namespace name 'RoomInfo' could not be found

$
0
0
Since I had bought PUN beforehand I decided to go ahead and upgrade to PUN 2 to see if that would help with network smoothing and so on at all. I got a bunch of assembly reference errors that I managed to fix myself but for some reason a RoomInfo one still stays,
error CS0246: The type or namespace name 'RoomInfo' could not be found (are you missing a using directive or an assembly reference?)
Is there a using somethingorother that I've missed specifically for rooms now?

Have some questions in PlayFab and PUN

$
0
0
HI I would like to ask some questions related to PUN and the PlayFab. - PlayFab has any API to create Photon Room? So, PlayFab will manage the Networking as the Backend of the Unity App. Once PlayFab creates a room of maximum 4 players, 4 players can see a room created by PlayFab API and they can only join the room, can't create room themselves. Once the room is full, the PlayFab creates a new room for new players will be joined. But we can manually create any room on PlayFab side. So is this possible for PlayFab? - I think PlayFab can create the Photon Room and sure, but I want to know that PlayFab can create multiple rooms. - If can create multiple rooms then how many rooms? If I buy 500 CCU then? Please kindly help me I look forward to getting answers. Thanks!

Is there a way to limit the maximum number of global users able to connect?

$
0
0
I know there's a hard limit that prevents a certain amount of concurrent users from connecting globally to the master server anyway but is there some way I can code in my own limit? For example, If I have 100 max users, can I put in a limit of about 40 if I want to?

How to create many rooms (at least 100+)

$
0
0
Well... I am going to buy 500 CCU or more. I am also going to create many rooms in something like a web admin panel with a button click There is a button "Create A New Room" in the admin panel. Each time clicking the button, a new room with a suffix will be created. And I want to create many rooms. Hmm... I think 1 unity instance can create only 1 room. So, In my opinion, to create 100 rooms, I need to run 100 instances (they only creates the room and they are the master clients) The other instances(clients) only join the room, they don't have any function to create the room themselves. If no room is available they can't join any room and need to wait until a room is empty. I want to know how to create rooms in admin panel Anyone who knows this please help me I will be waiting Thanks

Write to stream in OnPhotonSerializeView without using SendNext method

$
0
0
Hey guys! I'm trying to figure out the best way for reducing the packet size of my messages I'm sending to all clients. I'm using OnPhotonSerializeView to keep my objects synchronized. The Photon documentary says that the SendNext method is writing the size of the current data type for each value to the stream aswell. As a result the smallest possible value (byte) is at least 2 bytes in size (1 byte for size, 1 byte for value). In my case this almost doubles the packet size of my messages and it's completely unnecessary. I'm wondering if there is a way to avoid using the SendNext method. I know the order and the size of my sent values so in my case i really dont need the extra bytes for sending data type sizes. I'm looking for something like stream.Write(object[]) but inside OnPhotonSerializeView. Thank you for your support!

Matchmaking

$
0
0
Hello. We have an online game, rooms 5x5 players There is such a problem When all rooms are full, we create a new room. And if 2 players click Play at the same time, 2 new rooms will be created, so new players will be divided into 2 rooms. How to solve this problem locally, without server logic? Any ideas?

Can't Find Appropriate Namespace for PhotonNetwork

$
0
0
Hello. I'm just starting with PUN, been working in Unity for about 3 years. I picked up the tutorial here: https://doc.photonengine.com/en-us/pun/v1/demos-and-tutorials/pun-basics-tutorial/lobby, and right off the bat I'm having trouble finding variables. I'm using Unity 2018 3.0 and have downloaded PUN v 1.93 from Unity Asset Store. I'm having trouble with step 5... writing the Launcher practice code. I copied and pasted it from the website to verify it was not a mistake on my end (typos). 5) PhotonNetwork.autoJoinLobby = false; // PhotonNetwork does not exist in this current context. So I did some searching and added Using Photon.Pun; which only fixes PhotonNetwork. Now the same line. 5) PhotonNetwork.autoJoinLobby = false; // autoJoinLobby does not exist in this current context. Am I using a version of Unity that is not supported? (PUN claims 5.3.7 or higher)? I'm not sure where to go from here besides seek a different engine.

Duplicate OnLeave callbacks while playerTtl > 0

$
0
0
Hi! I have a room with playerTtl equal to 20000 and a couple of players within it. If any of those players has connection problems then OnLeave callback is called twice: the first time is not exactly after the player has left the room but a bit later and the second time is (or seemed like) the playerTtl period after the first one. So I wonder if this is the expected behaviour? If it is, why is it so and is there a way to detect if this was the first callback for the exact player or the second?

Object intercation in the scene

$
0
0
Hello everybody. I have a project with photon and vrtk plugin, the various players see each other and their positions are updated. In the scene there is an interactive sphere that has photon view, photon transform view, photon rigidbody view and VRTK Interactable object. Now if a client takes the ball and moves it he sees that it has changed position, but the master client does not. If the master client takes the ball and then another player tries to take it, it returns to the master client. I do RPC call which change the color of sphere and this works well. Help me please :)

How do I transfer ownership of an object?

$
0
0
I have a room where players can connect and move around using the default FirsPersonController. I've made a vehicle that can be exited and entered and it's all synchronized, but there is a problem. Only the host of the game can drive the car around. The host can see other players entering the car, but they are only able to drive the car on their own screen(the host sees them in the car standing still). After some digging, I realised this is due to the Owner property of the PhotonView component being set to fixed. This means that other players were trying to move a car that didn't belong to them. I looked into the documentation for RequestOwnership() and after trying to pass various IDs from PhotonView and PhotonNetwork through it, it didn't work. My question is, how do I transfer the ownership of my vehicle to the player that enters it? I am using PUN v2.

How to determine if the player REjoined the room?

$
0
0
Hi to all! For example: Disconnected players in my game are replaced with bots. After player has rejoined the room the OnJoin() callback is called and I have to replace one of the bots with a player. But if this is a new player who has just joined the room the OnJoin() callback is also called but I dont have to do anything. So the question: is the a way to figure out if this is a join or REjoin? P.S. I'm sorry for my English!

[Pun2] Room Properties not set

$
0
0
Hello, im tryin to port my Project from pun classic to Pun2. Working well so far until i created a Room. I add CustomRoomPopertries in PhotonNetwork.CreateRoom. see here : https://pastebin.com/wrf8c2Av But when i try to get the props i get null reference Error. see here: https://pastebin.com/0SBiv8KK It works perfect in Pun Classic, so did anything changed ?

PunTurnManager Help

$
0
0
Hi I am using PunTurnManger in my game and getting an error. I was hoping someone might know what is wrong. Here is the process: Master calls "BeginTurn". All players receive "OnTurnBegins". When a player ends their turn, I iterate over all players to check if they have finished their turn, this is where the error occurs. If the Player is not the master i get a Null reference error on this line: (int)room.CustomProperties[propKey]; The room does not contain the propKey... Why might that be?
/// 
        /// gets the player's finished turn (from the ROOM properties)
        /// 
        /// The finished turn index
        /// Player reference
        public static int GetFinishedTurn(this Player player) {
            Room room = PhotonNetwork.CurrentRoom;
            if (room == null || room.CustomProperties == null || !room.CustomProperties.ContainsKey(TurnPropKey)) {
                return 0;
            }

            string propKey = FinishedTurnPropKey + player.ActorNumber;
            return (int)room.CustomProperties[propKey];
        }

Prefab GUIDs changing in 2019 beta

$
0
0
We're having a strange issue with prefabs that have a PhotonView component seemingly having their GUID changed and causing missing references in various components/ScriptableObjects throughout the project. Help!

Move All Players to a Position?

$
0
0
What i want to do is, when a player changes the level, i want to lerp each players position to the spawn position. How can i do this? i tried syncing a boolean that tells whether we should be lerping or not, but it just returns weird movement

How to check if RPC function exists before calling RPC function

$
0
0
Hi @Tobias I want to check if RPC function exists before calling the function. CHECK IF RPCCALL1 EXISTS IF YES photonView.RPC("RPCCall1", PhotonTargets.MasterClient, PhotonNetwork.player); ELSE SKIP Thanks

how to get available room list in PUN2 ( V2 )

$
0
0
can't able to use PhotonNetwork.GetRoomList();

backgroundtimeout not working in photon2.5

$
0
0
i have using photonnetwork.backgroundtimeout=10 sec it worked it photon2.2 but in photon2.5 it taking 20 sec even i had changed to 10 sec

Seperate Turn Duration for each player in Turn based games

$
0
0
In my game There are Two Players ,I want to give separate turn duration for each player,and when the turn Duration expires the turn should be passed to opponent player, i am assigning 30 seconds to turnManager.TurnDuration. When TurnDuration Expires both players passes the turn,but i don't want to do like this i just want to send only only players turn how to to this can anyone tell me.
Viewing all 8947 articles
Browse latest View live


Latest Images

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