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

Instantiating Local Objects

$
0
0
Hello, how do I instantiate an object only locally? I have this objective object, and when you walk to it, it destroys itself and announces in chat that you did it; however, it destroys it for everyone and announces in chat that everyone did it. How do I do this locally? I use Instantiate().

OnDisconnectedFromPhoton not called

$
0
0
Hi, I am having a strange issue where OnDisconnectedFromPhoton is not called. I just disable the WIFI. After around 1 min it throws socket exception but nothing is called. Sorry it is not throwed but printed

Reconnecting to photon server.

$
0
0
Hi,
I have an issue about reconnecting to photon server when when network is lost.
To do it, I have set disconnection timeout in both client and photon server by using "PhotonNetwork.networkingPeer.DisconnectTimeout" in client side and config "InactivityTimeout" in photon server side.
I hope when network is lost, client will wait during the timeout period (to reconnecting) before the event "OnConnectionFail" and "OnFailedToConnectToPhoton" are triggered .
But when I debugged, 2 event "OnConnectionFail" and "OnFailedToConnectToPhoton" are triggered as soon as the network is lost with the cause is "DisconnectByServerTimeout"
I don't know why the "timeout" parameter I set haven't effect.

How does the Msg/s count scale with multiple players?

$
0
0
Let's say you send an RPC from P1 to all other players.

If only P1 and P2 are in the room, that counts as 1 message.

If there is a P3 too, does it count as:
A. 2 messages (P1 to P2, and P1 to P3).
B. 1 message (RPC from P1, regardless of how many other players it gets sent to.

The reason I'm asking is to be able to extrapolate how many messages there will be with more players, if I can only test with a limited number of people at a time. Any other tips for this are welcomed too.

SpawnPosition, weird behavior

$
0
0
Hallo,
im tryin to Explain.
If 2 Players join a Room, only the MasterClient can Start the Match. MasterClient start the Match and via
PhotonNetwork.LoadLevel("Room for " + PhotonNetwork.room.PlayerCount); Like in the Tutorial the correct Room get Loaded.

Now the GameManager recieve spawnPositions from SpawnPoint.cs wich placed empty GameObjects .

SpawnPoint.cs
public bool playerLocated = false; private void Start() { GameManager.Instance.spawnPosition.Add(this); } public void RPCCall() { photonView.RPC("Located", PhotonTargets.AllBuffered, true); } public Vector3 GetPosition() { return transform.position; } [PunRPC] void Located(bool value) { if (!playerLocated) playerLocated = value; }

then the GameManager start to for (int i = 0; i < spawnPosition.Count; i++) { if (!spawnPosition[i].playerLocated) { CreatePlayer(i); } }
GameObject player = PhotonNetwork.Instantiate(this.playerPrefab.name, spawnPosition[i].GetPosition(), Quaternion.identity, 0);
after this i call
spawnPosition[i].RPCCall();
so it marks the playerLocated bool to true
now the next Instantiated player cant use the same Position, thats what i think.

if the FirstPlayer(MasterClient) is the UnityEditor and the 2nd Player is a Build Instance this works perfect every player get spawned at a unique spawnPoint.
But if the FirstPlayer(MasterClient) is the Build Instance and 2nd Player whatever they both get Spawned at the same Place.
any Help pls?

Turn based Multiplayer game create room join other can join the room, if its not reach max player

$
0
0
i need like this Player1 connects to photon and creates room if there are no rooms, Player2 connects to photon and joined to the room which has been created by Player1. So the room is full (because I set maxPlayers to 2)
Now there is a new player Player3. Is Player3 will create a new room? because when I have used codes from "Sky Arena" my Player3 couldn't created a new room. Unity Editor console says "The Room is Full".After enter to room the suppose have his first turn like roll the dice and he gets 5 and finish his move now the second player turns, at this point how i can restrict player 1 he can't do anything until unless player 2 finished his move.

PhotonNetwork.JoinRoom problem

$
0
0
Hi,

I've got problem with JoinRoom(name) function.

I want to join room by name when someone else created private room and share room name.

It's working fine but I've got weird problem.

When I try to join room by name and this room doesn't exist then I expected I should receive message that room doesn't exist and I cannot join it but instead this room is created. I thought it should work like that in JoinOrCreate rather than in JoinRoom.

Can anyone help me?

Need help with doing nicknames, leaderboards and printing names on players

$
0
0
Hey guys, i have tried to code nicknames and can't really think of how to do the rest :/ as it just seems really different.
Here is my code to start with:

using System.Collections; using System.Collections.Generic; using UnityEngine; using UnityEngine.UI; public class Nickname : MonoBehaviour { public Text infoText; [Header("Nick Panel")] public InputField nickInput; private string nickname; // Use this for initialization public void NickPanel_OkBtn() { if (Input.GetKeyDown (KeyCode.Return)) { this.nickname = nickInput.text; PhotonNetwork.player.NickName = this.nickname; Application.LoadLevel ("Game"); } } }

If I buy 2 x PUN Plus packages will i get 200 CCU?

$
0
0
I currently have 1 x Pun Plus package. If I buy another do I get 200CCU on the same package?

Synchronizing a missile (projectile)!

$
0
0
Hello everyone, I'm having trouble synchronizing a bullet in my game! It behaves like a missile, and I need to make sure the projectile is in the same position on all machines!

Doing a position compensation, I can not guarantee that! I know I'm doing something wrong, because we see this guarantee in some games, like the Pharah missile in Overwatch, or the rocket launchers in Quake Arena, etc...

private void FixedUpdate() {
    if (PhotonNetwork.isMasterClient)
     {
          myRigidbody.MovePosition(myTransform.position + myTransform.forward * Time.deltaTime * speed);
     }
     else
     {
          lerpFraction = lerpFraction + Time.deltaTime * 9;
          myRigidbody.position = Vector3.Lerp(currentPosition, networkPos, lerpFraction);
     }
}

Rigidbody addForce on other Player

$
0
0
Hallo,
I'm looking for a workflow/Solution, to rigidbody.AddForce to other Players-GameObject-Rigidbody. Basically I do a SphereCast to get all near Colliders->Rigidbody, then calculate the direction and Rigidbody.AddForce to other Players-Rigidbody, but this way dont work on a Network.

I'm looking for a work around or somthing that could help.

Crash in SetInterestGroups method when providing new byte[0] as parameter.

$
0
0
Hello,

I've updated PUN to the latest Version 1.86.1
The method SetInterestGroups results in an Unity crash at line:

for (byte index = 0; index <= byte.MaxValue; index++)
{
this.allowedReceivingGroups.Add(index);
}

If I change "<=" to "<" it works.

Greetings!

BUG PhotonAnimationView is buggie when deleting Parameters (unless script is removed and added)

$
0
0
Hello

I just found this bug that was quite puzzling me

Steps to reprodude

1. On your character with Animator add a PhotonAnimationView
2. Set some of the Parameters to Discrete
3. create prefab
4. now go to the animation controller and delete some parameters (I know this is quite rare use case because you dont often delete parameters, I guess)
5. now Test your game (2 players minimum)

actual behavior
you will get error that says your deleted parameters failed to synchronize.
then you look into the PhotonAnimationView but the deleted parameters are not there
so you wonder where this come from.

expected behavior
no errors should be thrown and animation should be synchronized

How to resolve this?
Remove the PhotonAnimationView from the GameObject and add it again.
set again your parameters to Discrete (little annoying especially when you have many parameters in the Animator Controller)


Cheers


PhotonNetwork.GetRoomsList() Not working (autojoinlobby is on, waited for onJoinedLobby)

$
0
0
There are currently 4+ rooms going. When I call for PhotonNetwork.GetRoomList() AFTER onJoinedLobby(), I get 0 each time (not in a room)

It seems to work *later*, but how later? Is there a callback I'm missing that comes *after* OnJoinedLobby?

adding PhotonTransformView programatically

$
0
0
Hi

Is there a way to add PhotonTransformView component to your object programmatically? I have to add it to tons of objects if I do it manually on each prefab and I'm sure you can do addComponent on it from a script but the problem is that I don't seem to have access to enable the synchronize position/rotation from script and all its parameters. Is there a way to do it?

Bug Dashboard Statistics (kinda nonsense)

$
0
0

See the Screenshots below

I knew from the very first moment when I saw the very poor and catastrophically designed graph something must be wrong.
Same as this entire forum the design is crap.

Plus the statistics are wrong

for the last 24 hours it shows me a peak of 276
https://imgur.com/a/ou4EF

for the last 7 days it shows me a peak of 116
https://imgur.com/a/2QBH0

aha . . .

if I filter by month peak is even getting lower loool 96

I Love Photon but UI is not your strength
(and I cant even upload images here?...)

gosh, get a SMF or phpBB forum please . . .

just frustrating in anything here and by the way Good Job hiding the Edit button after posting. it took me almost 10 minutes to find it


Drag race, car is super fast when on slower device verses same car on faster device!

$
0
0
I have a drag race game setup and all works fine except that running on iPhone7 which is fairly fast device against iPad4th Generation which is a slower device, automatically the car on the iPad4th Gen. is super fast! same code is running on both ends of course, so i don't see why this is happening? any guide or hint would be appreciated.

It's been driving me crazy for days, and i can't find a solution.
Of course tried that one device is master and another is client, and vice versa but nothing solved this. Car on iPad is super fast even without changing gears!!! by the way, both devices running exact same car with exact same configuration, since it comes out of the resources folder. I also tried different cars, even slow cars against fast cars, no matter what, still car on iPad is super fast and finishes the race first always!

Is there a big difference between few and many variables in the photonstream?

$
0
0
Hello,
I have a cargame where it is possible to pick up powerups for the car. Those powerups change the stats of the car, so it may have more power, better handling or something else.
In the photonstream where all the inputs are sent, I add the stats of the car to be sent aswell, so whenever something changes, it is shared accros the network.
Is it a bad idea to send all these stats in the stream, and should I just use RPCs whenever a stat change for one of the cars in the game? The reason I like attaching the stats in the stream, is because I avoid having alot of different RPC functions in the list, and there is no risk of stats not being synced, in case an RPC gets dropped.

My question is basically this: Is there a major difference in the network usage between a stream of 5 rarely changed variables. and a stream of 20 rarely changed variables?

Transform and Rigidbody View - Occasional strong stuttering, no lag

$
0
0
Hi,

I've achieved so far quite good result in my physics-based game using Transform and Rigidbody Views combined.

However, we sometimes experience strong stuttering of physic objects even though no lag is displayed.

Example: This is how well the game runs 80% of the time. The physics are calculated on the throwing player's side. Hope you see what I mean
https://giphy.com/gifs/l378BfzorxhwWwTAc

However, sometimes this happens
https://giphy.com/gifs/l378Ajp1r1MskvXMI

It's like a massive lag. I've recorded this playsession from both players sides and on no side I can see an increase in lag.

Can someone give me an idea what else might be causing this and how I can proceed to assess this further?

Thank you!

Room count / custom property?

$
0
0
Hi all,

I've been working on my multiplayer game now for a while, using Photon PUN (Unity). Btw great so far. I pretty much made all things I wanted in actual game session and am now moving to matchmaking bits.

To give a bit of background heres what I have now:

1. N unity scenes to play on
2. Player picks one
3. Room is created or joined based on custom property (scene index, simply)

Its a 2 player battle type game, btw.
All of the networking stuff is processed on scene load (main menu is not networked for now).

Now, I have following scenario I want to achieve and couple of related questions:

***

When player opens list of scenes available, I'd like to show number of open/available (or total if available is not possible) rooms for each scene on UI.
Matchmaking would still be random but since idea is that players can access more scenes (arenas) with more XP, it would be very helpful to see which scene/arena has people playing/waiting for match. Especially in case where there's low amount of players in game.

Something like:
Arena 1 [17]

Where 17 is room count with that custom property.

Based on my readings so far - I think I need to connect all players to photon in Menu scene and then count rooms by properties via RoomsList somehow. Is that right?

See I only need this info for visual/usability purposes in game.

Also, if that's the way to go - one important question: do connected users but not in room (like in this case - people upgrading something or similar in main menu) count towards CCU limit? I hope not :)

I'm a bit new to Photon all together so bear with me please, I hope I'm not asking too silly question :) Also typing on mobile do excusenany typos. Thanks in advance and keep up the good work.
Viewing all 8947 articles
Browse latest View live


Latest Images

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