Hi there.
I've recently moved to PUN2 after successfully using PUN for another project for two past years. Now I'm seeing an issue with custom types that I have not experienced in PUN.
When I try to add any of my classes to CustomTypes.cs, they are not found. I am getting the "are you missing a using directive or an assembly reference?" error. My classes are public and are not part of any namespace.
The thing is, when I move the CustomTypes.cs class outside of the Assets/Photon/PhotonUnityNetworking/Code/ folder and place it in my Assets/Scripts/ folder, my classes can now be accessed in this file. However, then I am getting the same "missing a using directive" error from PhotonNetwork.cs about missing CustomTypes class.
Now, I know some Unity folder names can make some classes inaccessible from others because of the compilation order (https://docs.unity3d.com/Manual/ScriptCompileOrderFolders.html), but none of these folder names exist in this scenario.
Any help would be greatly appreciated!
↧
PUN2 - Can't add my class to CustomTypes.cs - "are you missing a using directive..."
↧
My weapon objects are showing on both players, but dont sync on the local player, only the network.
How can I fix this? Both players switch weapons on my view when I switch weapons, and animations play on both players when i reload, or move around. I have a photon view component on the weapon holder, but they dont sync locally, what may I be doing wrong?
↧
↧
Connect() to 'ns.exitgames.com' (InterNetworkV6) failed
I have finished developing my games. I tested it and it works perfectly on the editor, my Samsung Note 9, and my Samsung Tablet. I tried to install it my older phone Galaxy S7, and the game doesn't connect to the Photon cloud server in any way. I've set the region as Best Region with no luck. All devices connected on the same network. I don't understand what causes the issue on that device only. I'm afraid this will happen randomly with other users later. I've opened the device log and this is the error appearing:
Connect() to 'ns.exitgames.com' (InterNetworkV6) failed: System.Net.Sockets.SocketException (0x80004005): Network is unreachable
Please help...
↧
pun 2 automatically disconnected in android device
hello,
i am facing this issue when demo app run on android device.It works fine in another device and also in editor but not on my device
Connect() to 'ns.exitgames.com' (InterNetworkV6) failed: System.Net.Sockets.SocketException (0x80004005): Network is unreachable.
↧
Cannot connect to photon cloud
Hello!!
I just installed photon in Unity. I created an app type "PUN" and I pasted the ID in the setup PUN wizard. The server settings are on "Photon Cloud" with EU region. When I launch the photon demo on PUN basics-Launcher it never connects to the cloud and shows error "Disconnected" after a lot of infos like "Resending: CMD(2 ch#/sq#/usq#......."
Can someone help? I'm king of a noob in networking and I'm really stuck.
↧
↧
Only shoots when moving
I'm doing a multiplayer top-down shooter. The problem is that the bullets are only spawned when the player spawning them is moving, they wont otherwise.
Hope you can lend me a hand with that.
Here're the codes.
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using Photon.Pun;
using System;
public class powerUps : Photon.Pun.MonoBehaviourPun
{
public bool bow;
public bool speed;
public bool autoheal;
public bool trees;
public bool attackSpeed;
public float timerBow;
public float attackSpeedTim;
public GameObject flecha;
public GameObject projectileSpawner;
public float proyectilSpeed;
public float autohealTimer;
public float autohealDelay;
public float autohealAmount;
Player player;
GameObject PlayerBody;
// Start is called before the first frame update
void Start()
{
bow = false;
speed = false;
autoheal = false;
trees = false;
attackSpeed = false;
proyectilSpeed = 1f;
attackSpeedTim = 1.5f;
autohealDelay = 5;
autohealAmount = 2;
player = gameObject.GetComponent();
PlayerBody = player.playerBody;
}
// Update is called once per frame
void Update()
{
//BOW
if (player.PlayerOn)
{
if (bow)
{
if (timerBow < attackSpeedTim)
{
timerBow += Time.deltaTime;
}
else
{
if (Input.GetMouseButton(0))
{
if (timerBow >= attackSpeedTim)
{
AtacarBow();
}
}
}
}
if (autoheal)
{
if (autohealTimer <= autohealDelay)
{
autohealTimer += Time.deltaTime;
}
else
{
if (player.health <= 100)
{
player.addHealth(autohealAmount);
autohealTimer = 0;
}
}
}
if (Input.GetKeyDown(KeyCode.H))
{
player.addHealth(-90);
}
}
}
void AtacarBow()
{
Quaternion rotation = PlayerBody.transform.rotation;
this.GetComponent<PhotonView>().RPC("spawnShot", RpcTarget.AllBuffered, flecha.name, projectileSpawner.transform.position, rotation);
timerBow = 0;
}
public float getProyectilSpeed()
{
return proyectilSpeed;
}
public void setProyectilSpeed()
{
}
[PunRPC]
void spawnShot(String name, Vector3 position, Quaternion rotation)
{
GameObject clonflecha = Photon.Pun.PhotonNetwork.Instantiate(flecha.name, projectileSpawner.transform.position, rotation, 0);
clonflecha.GetComponent().creador = gameObject;
clonflecha.GetComponent().velocidad = clonflecha.GetComponent().velocidad + proyectilSpeed;
Debug.Log("Disparando");
PlayerBody.transform.position = new Vector3(70, 18, 70);
}
}
↧
ConnectUsingSettings() doesn't work
I am following this tutorial and I am facing a problem. On Start() the editor should connect to the master server and write to console the region it is connected to but it doesn't. My console window is empty. Here is the code:
using Photon.Pun;
using Photon.Realtime;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class NetworkController : MonoBehaviourPunCallbacks
{
void Start()
{
PhotonNetwork.ConnectUsingSettings(); //Connects to Photon master servers
}
public override void OnConnectedToMaster()
{
Debug.Log("We are now connected to the " + PhotonNetwork.CloudRegion + " server!");
}
}
↧
"'AudioSpeakerMode.Raw' is obsolete"
Hi! I'm using the latest stable Unity version (2019.2.0f1) and the latest PUN 2 + Voice 2 (my build target is Android). All works fine, except I'm getting this single error:
Assets\Photon\PhotonVoice\Code\WebRtcAudioDsp.cs(43,14): error CS0619: 'AudioSpeakerMode.Raw' is obsolete: 'Raw speaker mode is not supported. Do not use.'
Out-commenting the line in question, {AudioSpeakerMode.Raw, 0}
, fixes the issue. I did wonder though what this was. Thanks!
↧
IS there an example of CAS anywhere?
I tried this over on the Unity forums with no luck.
Does anyone have a code example for changing a RoomProperty in Photon using CAS, that includes the error handling?
I have a float[] as a custom property. The various players can change elements of the float array. However, because of concurrency, while I try to change one element, another player may try to change a different element.
Ultimately what I am looking for (psuedocode)
ChangeRoomProperties()
{
ReadRoomProperties() //casting them to an array[]
alter the desired element
recreate Hashtable
room.SetCustomProperties(prop, oldvalueProp);
if error == incorrect oldValueProp
{
ChangeRoomProperties()
}
}
↧
↧
PUN architectural strategy
Hi!
I am working on a project where we need about 200 GameObjects per player, (max 2 players, so a total of about 400-500), to sync their position and rotation. Is this too much to have a PhotonView component per GameObject?
If ("yes")
{
What is a better strategy?
}
Note: some of these GameObjects are grouped in about 20 groups per player. Should those 20 objects instead report their children objects change of position & rotation?
↧
Timeout-Disconnect to photon server
Hello everyone!
I cannot seem to launch photon properly in my unity environment. Each time I try to launch a photon demo, it never connects I think and sends back error messages such as :
- Timeout-disconnect! Command: CMD(2 ch#/sq#/usq#: 255/1/0 r#/st/tt:8/7520/10114) now: 14611 challenge: 62d3c7ff
- Resending: CMD(2 ch#/sq#/usq#: 255/1/0 r#/st/tt:7/3998/10114). times out after: 3520 sent: 3998 now: 7520 rtt/var: 200/5 last recv: 9629
It seems to be having a problem starting from :
IPhotonSocket.Connect() ns.exitgames.com:5058 this.Protocol: Udp
Can some one tell me where the problem might be coming from?
↧
Method to pause outgoing messages? Or method to tell client to set isMessageQueueRunning to true?
Hello, I'm having an issue with players joining a game and while they're awaiting the MasterClient to initialize the scene and then send the the fully loaded game state, the MasterClient sends some intermediary RPCs, which the joining client doesn't exactly know how to handle, because they haven't received the full game state yet. Specifically, in a number of my intialization methods, a lot of network objects send messages over the network.
I realize I could check in each of those RPC calls if it's coming from the MasterClient and then check if the MasterClient has 'finishedLoadingLevel', but I'm I'm realizing this late and that's a lot of methods I'm going to have to find and I would prefer to not have that check in every function that sends a network message. I realize I can toggle off PhotonNetwork.isMessageQueueRunning for the joining player, but then I don't know how to tell that player to turn the queue back once the MasterClient is done setting up the level. If there were something that I could toggle on the MasterClient like PhotonNetwork.isSendingMesssages, then I could toggle that off, initialize the level, toggle it on, then send the game state out to any other players in the room waiting for the game state.
Thanks for reading :)
↧
Loading different clients based on room
I would like to be able to have certain clients load into a level. Currently I have all clients joining a single room and the master client putting them into groups. In each group there is a start button which when pressed I would like those that are in the group to go to that level. Any ideas on how I could accomplish this?
↧
↧
Cross Platform Connecting Demo
I built the Asteroids demo for Android and PC just to see if it worked. They do not see each others' rooms. What do I need to do to have them be able to be in the same room?
↧
Photon VR
Hello everyone,
I am doing a multiplayer VR in Unity, I have been able to get most of the stuff correct, however whenever a second player joins, the second player's teleportation is messed up. Whenever it points at a floor and teleports, it moves the character, but not the camera. I use the same prefab from Resources folder to instantiate players, the first player works quite fine however the second player is always messed up. Is there anyone who can help me with this?
↧
Synching AnimationClipPlayable
Hello,
I've so far got transform synching working and am trying to get the animator synching as well.
Specifically the issue is that I am using AnimationClipPlayables to play my animations (required for an unrelated reason).
public void PlayRandomAnim () {
graph = PlayableGraph.Create ();
graph.SetTimeUpdateMode (DirectorUpdateMode.GameTime);
animationClipPlayable = AnimationClipPlayable.Create (graph, animationClip);
animationClipPlayable.Play ();
// Connect the Playable to an output
AnimationPlayableOutput playableOutput = AnimationPlayableOutput.Create (graph, "Animation", animator);
playableOutput.SetSourcePlayable (animationClipPlayable);
// Plays the Graph.
graph.Play ();
}
So my question is, are AnimationClipPlayable supported by PUN?
Thanks!
↧
Networking Line Renderer
How To Make Networking Line Renderer, i had did the following steps but it wont working
1.Photon Transform view for Line renderer.
2. Send The LineRenderer Position using LineRenderer.setposition(0,Vector3) and LineRenderer.setposition(1,Vector3) in OnPhotonSerialization function.
Please Let me Know the solution.
Thanks in Advance.
↧
↧
Feature wish: Get Room list while in a room (without workarounds)
Hi! It would be amazingly useful to get the active room lists without having to use these type of server side/ second peer workarounds. Thanks for considering!
↧
Create second peer on client?
Hi! Is there an example project or example code on how one would create a second peer on the client (to poll the lobby room list)? (I'm seeing an older thread here on this but without answers.) The functions I'm using to create the first peer, like
if (!PhotonNetwork.IsConnected)) { PhotonNetwork.ConnectUsingSettings() }
, seem to be more global and singular in nature. Thanks!
↧
About Syncing the game state
Hi,
I am building a game where the you can invite friends to a lobby (4 players max).
And the lobby is already inside the room, I'm implementing a lobby with real-time features like (chat with RPC's) and emotions triggering with RPC (smile, cry, dance.. etc..)
Now every player can click ready and the admin can click start game when all players in the lobby are ready.
So first of all,
1) how do I sync the ready state? I use each player custom props, and I use a OnPhotonPlayerPropertiesChanged on the player prefab, that sets a checkmark next to ready players.
all players check if (PhotonView.IsMine && PhotonNetwork.IsMasterClient) and if it's true, they itterate all players custom props and check if all are ready, if they are, enabling the start button, if not, disabling it (for the admin only).
2) How do I let all players know about changes as the master client? For this I'm less sure about my path, but will love to hear best practices :smile: .
When click "Start Game" as the admin, I'm changing the rooms custom props, and all players are listening to OnPhotonCustomRoomPropertiesChanged and fire up multiplayer game procedure functions like, ['Announce players', 'Start Game', 'Game Ended', 'Announce Scores', 'Announce Winners', etc.....].
So are those 2 ways of implementing this is fine? are there maybe any better ways? maybe best practices? because I need to let all players know exactly when the game starts
Thanks you all in advance! :D
↧