Hi guys,
I want to create waiting rooms like in Fotrnite or Counter-Strike: Global Offensive, but I have a problem with doing it. Please help I don't know how to do this.
↧
Waiting rooms with some friends
↧
Calling an RPC on a different object/class
Hi, I'm trying to call an RPC on a scene object, the scene's game controller, from a UI object but it doesn't seem to be received on any object. Is this not possible? Calling this from a UI class/object to send to the Master Client:
Controller.instance.photonView.RPC("AddObject", RpcTarget.MasterClient, name);
But nothing seems to happen. Thoughts?
↧
↧
The Headache of PhotonNetwork.Instantiate's initial position
When using PhotonNetwork.Instantiate, objects are initially spawned at their initial spawn location for a single frame before being updated to their actual "current" position a frame later. This is disastrous for objects with rigidbodies because they will collide with the old "ghosts" of any object that was spawned at that same position in the past. Since this is a deep collision, it will usually send newly spawned objects flying off in crazy directions.
To elaborate further, here's the scenario:
1. Player 1 joins a room
2. We PhotonNetwork.Instantiate a new vehicle for him at position 1000,20,1000 in the world.
3. He appears correctly at the new position (which is a few meters up in the air above the ground), his vehicles drops down onto the ground, and he drives off into the distance. All's well so far.
4. Player 2 joins the room
5. We PhotonNetwork.Instantiate a new vehicle for player 2 at position 1000,20,1000 in the world.
6. For a single frame, on player 2's client, player 1's vehicle is spawned at its ORIGINAL position of 1000,20,1000! <== THIS IS THE BUG
7. Player 2's newly spawned vehicle is now inside of the player 1's original vehicle so they collide and go flying off into space
8. One frame later, player 1's vehicle is moved to its actual world position which is no longer at the spawn point, but this it too late - the collision has already happened
9. Player 2 gazes in wonder as his vehicle rockets miles up into the air, wondering what's happening.
Is there anything we can do about step #6 in this flow with PUN?
For now, the ugly hackish workaround I'm doing is to spawn all new player vehicles at s temporary starting point, which is semi-guranteed to be unique for each spawn, and then wait a frame before moving it to the actual spawn point. Ugly.
Any way to make PUN wait for a read of a PhotonView prior to the instantiation, or to pass some required data (like position) as part of the Instantiation, or anything we can do about this?
Thanks!
To elaborate further, here's the scenario:
1. Player 1 joins a room
2. We PhotonNetwork.Instantiate a new vehicle for him at position 1000,20,1000 in the world.
3. He appears correctly at the new position (which is a few meters up in the air above the ground), his vehicles drops down onto the ground, and he drives off into the distance. All's well so far.
4. Player 2 joins the room
5. We PhotonNetwork.Instantiate a new vehicle for player 2 at position 1000,20,1000 in the world.
6. For a single frame, on player 2's client, player 1's vehicle is spawned at its ORIGINAL position of 1000,20,1000! <== THIS IS THE BUG
7. Player 2's newly spawned vehicle is now inside of the player 1's original vehicle so they collide and go flying off into space
8. One frame later, player 1's vehicle is moved to its actual world position which is no longer at the spawn point, but this it too late - the collision has already happened
9. Player 2 gazes in wonder as his vehicle rockets miles up into the air, wondering what's happening.
Is there anything we can do about step #6 in this flow with PUN?
For now, the ugly hackish workaround I'm doing is to spawn all new player vehicles at s temporary starting point, which is semi-guranteed to be unique for each spawn, and then wait a frame before moving it to the actual spawn point. Ugly.
Any way to make PUN wait for a read of a PhotonView prior to the instantiation, or to pass some required data (like position) as part of the Instantiation, or anything we can do about this?
Thanks!
↧
why is my PUN project crashing my Unity editor the day after, but the standalone build works fine?
I followed a pun tutorial last night on unity 2018.2 and had a working project. This morning, unity crashes when i try to open project, BUT the standalone build works fine!? How do I fix this? My unity editor only crashes when opening working Pun projects!
↧
Can’t destroy gameObject of the disconnected user
Hi there,
I’m really stuck with the problem when gameObjects of the disconnected users are not destroyed neither by auto clean nor by calling PhotonNetwork.DestroyPlayerObjects() in the OnPhotonPlayerDisconnected event (which just executes without any errors, but don’t really do the work).
I have photonView script attached for the player prefabs and when they disconnect the «owner» property is changed to «null, disconnected?», but the object itself just keeps appearing in the game. I even tried calling PhotonNetwork.Destroy(gameObject) when photonView.owner == null, but got the «Cannot call Destroy on the gameobject as we don't control it» error (naturally, as «null» is its owner >_<).
I tried searching for relevant issues in the web, but with no luck. I found somewhat close topic (viewtopic.php?f=17&t=1344 ), but the NetworkingPeer.cs script that was given there don’t work with the latest PUN library…
I just run out of ideas what can prevent gameObjects from being clean out, and will be grateful for any tips. Thanks!
I’m really stuck with the problem when gameObjects of the disconnected users are not destroyed neither by auto clean nor by calling PhotonNetwork.DestroyPlayerObjects() in the OnPhotonPlayerDisconnected event (which just executes without any errors, but don’t really do the work).
I have photonView script attached for the player prefabs and when they disconnect the «owner» property is changed to «null, disconnected?», but the object itself just keeps appearing in the game. I even tried calling PhotonNetwork.Destroy(gameObject) when photonView.owner == null, but got the «Cannot call Destroy on the gameobject as we don't control it» error (naturally, as «null» is its owner >_<).
I tried searching for relevant issues in the web, but with no luck. I found somewhat close topic (viewtopic.php?f=17&t=1344 ), but the NetworkingPeer.cs script that was given there don’t work with the latest PUN library…
I just run out of ideas what can prevent gameObjects from being clean out, and will be grateful for any tips. Thanks!
↧
↧
RPC from a child object?
I want to add weapon pickups and I'm stuck, as the only way i can add the pickup is to make the weapon a child of the player. However, this means the gun can't shoot as it can't call the RPC. How can i get around this?
↧
1.8 DestroyPlayerObjects not work anymore
public void OnPhotonPlayerDisconnected(PhotonPlayer player)
{
if (PhotonNetwork.isMasterClient)
PhotonNetwork.DestroyPlayerObjects(player);
this does nothing after i updated to 1.8, in 1.6 they removed always automaticly
PhotonPlayers are removed but not photonViews lol
Tobias, in workerDemo create room, join here and leave, the player stays here(its not removed). When 1.9 come :P?
{
if (PhotonNetwork.isMasterClient)
PhotonNetwork.DestroyPlayerObjects(player);
this does nothing after i updated to 1.8, in 1.6 they removed always automaticly
PhotonPlayers are removed but not photonViews lol
Tobias, in workerDemo create room, join here and leave, the player stays here(its not removed). When 1.9 come :P?
↧
Make room only open to players who have connected before.
Pun Classic
I do random matchmaking with PhotonNetwork.JoinRandomRoom(). Once the room is full and "active" (in my case, two players) I want the room to no longer be considered for matchmaking but I do want the players who have joined successfully to be able to reconnect later should they have an unexpected disconnect. I don't want to close the room as I believe this stops anyone from joining, including those who have joined previously.
What's the recommendation on handling this sort of reconnect requirement?
↧
Rigidbody Erratic behavior on instantiation until input synchronization
Basically working on a 1 on 1 racing game. Using the PhotonNetwork.Instantiate using a PhotonTransformView object on the vehicles.
Problem: When the networked (not the master client) is spawned it is erratic until the opponent uses the vehicle controls and then it receives the synchronization changes and works as expected. I am at a loss on why when it first gets instantiated it goes forwards, backwards, bounces, and may stop against the barrier wall and as soon as the other player hits the throttle or some other input it snaps back to the starting line and takes off like normal with nice smoothing and everything? I was thinking maybe there was a way to force the position until the race started and then let synchronization take over but not sure how to approach that and not interfere with the photon functions.
I am still learning a lot and my first real time doing multiplayer so any help is appreciated.
↧
↧
object with don't destroy load, can't be seen
Hello, sorry for my bad English, it is not my mother tongue. The problem I have is that I have a motorcycle in an editor where players can edit it, then through a script (dont destroy load) I pass that bike without eliminating it to the playing scene where 2 players will connect to the room to play a race , but each client can see their motorcycle, but the other player's motorcycle is not visible on the client. How can I synchronize an object that is not destroyed at the scene, without having to use photon.instantiate
↧
RejoinRoom Problems
I was implementing reconnect to game functionality and saw this in RejoinRoom api documentation:
" Important: Instantiate() and use of RPCs is not yet supported. The ownership rules of PhotonViews prevent a seamless return to a game, if you use PhotonViews. "
Is this still the case? Is there any way to get around this? We're a long ways into building a MOBA and reconnecting to the game is critical.
↧
Implementing a Quick Play option?
I want to do the simple task of finding a random room, and if i cant find one, it makes one with the properties we need. Simple, right? Well no, as Photon doesn't seem to have support for finding out if you couldn't find a game. There's callbacks for it, but you can't actually override them. Is there any way i can do this? It's a bit silly how the developers haven't implemented this.
↧
Does the 500 Message Limit apply to the Photon Self-Hosted Server?
Foreword:
Although I am aware that 75% of all PUN users complain about this issue, I will not hold back my questions as they are unique to my application. Thank you for reading this.
Hello.
After managing to fit my game below 500 messages per second with only two players, I have found it nearly impossible to theoretically contain an ideal 10 players on a server with such a small traffic cap. I have come to realize many of my messages are linked to the master client's arena updates, as this game contains many objects and items that players regularly interact with and collect. Even with this being true, other players do generally produce a large sum of messages themselves, sometimes peaking at as much 100 each.
So in summary:
Does the game work with 2 players? Yes.
But will it work with even 3 players? No.
If there is a client related data-sending loop that is causing unnecessary messages and thus giving me the impression that the messages are natural, then I apologize for wasting your time. But if these messages are indeed true to the game's nature, then this is a major -1 on PUN Cloud for me. Although I LOVE Exit Games, and all of their products and brilliant staff that bring them to us, I can't help but wonder;
Is there something I am missing in my netcode, or is PUN Cloud the wrong platform for me?
I have heard fables that there is no message limit on PUN Server, and if this is true, then THAT is the platform I would use on launch, not a shared cloud server with hard limitations. And although I am aware that the 500 message limit is NOT an immediately acting cap, I have been booted from the cloud by message counts reaching ~550 prior to writing this.
So in summary:
If anyone with knowledge on the subject is reading this now, then please. For me and everyone else who encounters message-per-second based issues, settle this once and for all:
Does the Message Limit apply to Self Hosted PUN Servers?
Regards,
DarkJolt Games
↧
↧
Could a Self-Hosted Photon Server reach other countries?
Hello. I was just wondering, if I were to host my own PUN Server, then would it reach other countries, like the cloud?
↧
How to resolve DemoAsteroids compile error?
Hello, I bought PUN2. I use DemoAsteroids. I added scripts to Spaceship.cs for using Ultimate Joystick assett. Then compile error below displayed. please tell me what should I do? Perhaps namespace blocks.
Assets/Photon/PhotonUnityNetworking/Demos/DemoAsteroids/Scripts/Game/Spaceship.cs(90,24): error CS0103: The name 'UltimateJoystick' does not exist in the current context
Assets/Photon/PhotonUnityNetworking/Demos/DemoAsteroids/Scripts/Game/Spaceship.cs(91,28): error CS0103: The name 'UltimateJoystick' does not exist in the current context
Assets/Photon/PhotonUnityNetworking/Demos/DemoAsteroids/Scripts/Game/Spaceship.cs(96,17): error CS0103: The name 'UltimateButton' does not exist in the current context
script
using System.Collections;
using UnityEngine;
using Photon.Pun.UtilityScripts;
using Hashtable = ExitGames.Client.Photon.Hashtable;
namespace Photon.Pun.Demo.Asteroids
{
public class Spaceship : MonoBehaviour
{
public float RotationSpeed = 90.0f;
public float MovementSpeed = 2.0f;
public float MaxSpeed = 0.2f;
public ParticleSystem Destruction;
public GameObject EngineTrail;
public GameObject BulletPrefab;
private PhotonView photonView;
private new Rigidbody rigidbody;
private new Collider collider;
private new Renderer renderer;
private float rotation = 0.0f;
private float acceleration = 0.0f;
private float shootingTimer = 0.0f;
private bool controllable = true;
#region UNITY
public void Awake()
{
photonView = GetComponent();
rigidbody = GetComponent();
collider = GetComponent();
renderer = GetComponent();
}
public void Start()
{
foreach (Renderer r in GetComponentsInChildren())
{
r.material.color = AsteroidsGame.GetColor(photonView.Owner.GetPlayerNumber());
}
}
public void Update()
{
if (!photonView.IsMine || !controllable)
{
return;
}
//20191116 own from
//rotation = Input.GetAxis("Horizontal");
//acceleration = Input.GetAxis("Vertical");
rotation = UltimateJoystick..GetHorizontalAxis( "Movement" );
acceleration = UltimateJoystick.GetVerticalAxis( "Movement" );
//20191116 own to
//20191116 own from
//if (Input.GetButton("Jump") && shootingTimer <= 0.0)
if (UltimateButton.GetButtonDown( "Attack" ) && shootingTimer <= 0.0)
//20191116 own to
{
shootingTimer = 0.2f;
photonView.RPC("Fire", RpcTarget.AllViaServer, rigidbody.position, rigidbody.rotation);
}
↧
How to call an RPC from a child object?
My gun script is currently on the player and I want to add weapon switching. I don't want to add multiple gun scripts for the player because I can't expand that for pickups, and I can't parent the gun with the script already on it to the player, as the script needs RPC's to be called, and I can only call those RPC's from the actual player itself. Is there any way I can get around this?
↧
Getting huge message spikes, are there detailed message analytics?
Hello,
we're working on a realtime multiplayer mobile game using Photon 2. We're currently facing a problem with huge message numbers in certain areas, and are unable to trace the problems back to a source due to lack of analytics data. We have a solid knowledge of what goes through to the server from the client, but it seems somewhere in this flow something is causing massive message numbers and we don't really know what.
Is there any way to get more out of the analytics collected by Photon? We can see most areas running fine with less than 500 messages, but a select few (USA is one) are getting 60k+ message spikes every now and then with ~6 players in a room at once.
We've been optimising our network code for weeks now (stuffing everything possible into byte arrays, local calculation instead of networked etc.), and every time we think we reached a solution a new spike appears after a while.
Does Photon collect logs of sent/received messages on the server side that are available for developers to view? If not, how would we go about creating a log system to trace sent/received message information on the client? I don't need straight up code, I just need a red line to follow.
Google isn't very great when it comes to photon services... :D
Thank you in advance!
↧
↧
Error on Magic Leap regarding Photon View ID
Hi,
I have the following problem: I am implementing a multiplayer application with Photon 2 and Unity3D for the Magic Leap One. I have the following flow: First I show a menu, where a player can connect an opponent. When he selects the player, I load another scene. I am doing this between a PC and the glasses to be able to better test everything. When I load the second scene from the PC, everything is fine --> both the PC player and the glasses can play the game, but when I am loading the second scene from the glasses, then I instantly get back to the main menu and I am getting the following error:
: ArgumentException: An item with the same key has already been added. Key: 1
11-15 11:27:28.626 2674 1 E Unity : at UnityEngine.Playables.PlayableDirector.SendOnPlayableDirectorStop () [0x00000] in <00000000000000000000000000000000>:0
11-15 11:27:28.626 2674 1 E Unity : at UnityEngine.GridLayout.DoNothing () [0x00000] in <00000000000000000000000000000000>:0
11-15 11:27:28.626 2674 1 E Unity : at UnityEngine.GridLayout.DoNothing () [0x00000] in <00000000000000000000000000000000>:0
11-15 11:27:28.626 2674 1 E Unity : at UnityEngine.GridLayout.DoNothing () [0x00000] in <00000000000000000000000000000000>:0
11-15 11:27:28.626 2674 1 E Unity : at System.Collections.Generic.Dictionary`2[TKey,TValue].TryInsert (TKey key, TValue value, System.Collections.Generic.InsertionBehavior behavior) [0x00000] in <00000000000000000000000000000000>:0
11-15 11:27:28.626 2674 1 E Unity : at System.Collections.Generic.Dictionary`2[TKey,TValue].Add (TKey key, TValue value) [0x00000] in <00000000000000000000000000000000>:0
11-15 11:27:28.626 2674 1 E Unity : at Photon.Pun.PhotonNetwork.RegisterPhotonView (Photon.Pun.PhotonView netView) [0x00000] in <00000000000000000000000000000000>:0
11-15 11:27:28.626 2674 1 E Unity : at Photon.Pun.PhotonView.Awake () [0x00000] in <00000000000000000000000000000000>:0
11-15 11:27:28.626 2674 1 E Unity : at System.Collections.Generic.IReadOnlyDictionary`2[TKey,TValue].get_Keys () [0x00000] in <00000000000000000000000000000000>:0
11-15 11:27:28.626 2674 1 E Unity : at UnityEngine.GridLayout.DoNothing () [0x00000] in <00000000000000000000000000000000>:0
11-15 11:27:28.626 2674 1 E Unity : System.Diagnostics.StackTrace:init_frames(Int32, Boolean)
11-15 11:27:28.626 2674 1 E Unity : System.Diagnostics.StackTrace:.ctor(Int32, Boolean)
11-15 11:27:28.626 2674 1 E Unity : UnityEngine.StackTraceUtility:ExtractStringFromExceptionInternal(Object, String&, String&)
11-15 11:27:28.626 2674 1 E Unity : System.Collections.Generic.IReadOnlyDictionary`2:get_Keys()
11-15 11:27:28.626 2674 1 E Unity : UnityEngine.GridLayout:DoNothing()
Can anyone help me with this? I am using Unity 2019.2
Thanks a lot!
BR, Elisabeth
↧
Get router name
Hi everybody, and sorry for the n00b question.
I'm working on a project in which I'm using PUN 2 and Photon Server 4 on a local machine.
My customer asked me if there is the possibility to know the name, or at least a reference, of the router the Unity instance is connected to.
They need this information in order to monitor how much instances are connected to a single router, and so, how many different routers are involved in the network session (for example: a room with 6 players divided in 3 PCs on router 1, 2 PCs on router 2, 1 PC on router 3).
I tried to search something about that in the forum, but maybe I used the wrong keywords.
Thanks a lot for your time and your help!
Cheers
Riccardo
↧
[Tutorial] Launcher scene doesn't unload
Hi, I went through the quickstart tutorial and set up the 4 room battle. After I quit the application the Launcher scenes from runtime stays in the scene tree as "Laucher (not loaded)". Sometimes there are even 2 of those scenes in addition to the open Laucnher scene. When I switch to edit another scene it goes away but when returning to the launcher it is gone.
↧