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

OVRInput.Get stops working when instantiating local VR player

$
0
0
I'm having a weird issue, and while I don't think it's PUN's fault I'm hoping someone here may have run into the same issue and found a solution. When using PUN, the right thing to do (as I understand it) is to have the player be a prefab, and instantiate it on connect so the player is shown remotely too. Now, because the connection sometimes takes a little bit and I don't want to have just a black screen while it's going on, I have put an OVRCameraRig in my scene, so the camera is active and the user can see stuff (and move their head) as the game is connecting. All good so far. When we're connected, I destroy that camera rig and instantiate a new OVRCameraRig prefab as explained in the "Oculus Avatar" document linked earlier. Here's the weird thing: even though the camera works just fine and the user can look around (and see their hand), reading the status of the controller buttons does not work anymore: OVRInput.Get always returns false when I ask whether a button is pressed. I'm using this code to check the button:
bool pressed =  (OVRInput.Get(OVRInput.Button.PrimaryTouchpad));
If I remove the initial OVRCameraRig then things work again (including detecting button presses), but we have the black screen for a while during connection. Has someone else run into this, and found a way to switch from one OVRCameraRig to the other that works? I'm trying to avoid the black screen, or loading a whole new scene for now.

PUN2 Callbacks / Not being called

$
0
0
Long time user, using PUN2 now and had no issue before but seems the callbacks arent being fired now. i define using Photon.Pun and Photon.Realtime in the script as well as deriving from MonoBehaviourPunCallbacks I simply call the below in my connect method:
PhotonNetwork.GameVersion = "1";
PhotonNetwork.ConnectUsingSettings();
And wait for public override void OnConnectedToMaster() to be called but it never does. However, when i set the log level to all and such "Connected to masterserver" does get posted in the log so im quite confused.

InvalidCastException: Specified cast is not valid.

$
0
0
InvalidCastException: Specified cast is not valid. PlayerMovement.OnPhotonSerializeView (PhotonStream stream, PhotonMessageInfo info) (at Assets/Scripts/Game/PlayerMovement.cs:273) public void OnPhotonSerializeView(PhotonStream stream, PhotonMessageInfo info) { if (stream.isWriting) { stream.SendNext (transform.position); } else if (stream.isReading) { selfPos = (Vector2)stream.ReceiveNext(); } }

Scene Loading: Additive Scene Loading Questions

$
0
0
Hey everyone! I'm building quite a complex game here and I'd like a few tips about some of the structure. First of all, we have the entire game lobby on one scene, and the plan is to load the game scene after everyone joins the room and gets ready. We could use PhotonNetwork.automaticallySyncScene with no issues, but we'd like to have a loading bar for everyone and these sort of things. If it was singleplayer we'd probably do it by loading the scene additively, but I have no clue on how to achieve that with Photon. My second question is, at some point in the game, some of the players will have to play minigames, isolated from the others, and that would probably require another scene too. What should I do in this case? Thanks!

test

$
0
0
public class ReconnectController : MonoBehaviourPunCallbacks { private IEnumerator MainReconnect() { while (PhotonNetwork.NetworkingClient.LoadBalancingPeer.PeerState != ExitGames.Client.Photon.PeerStateValue.Disconnected) { Debug.Log("Waiting for client to be fully disconnected..", this); yield return new WaitForSeconds(0.2f); } Debug.Log("Client is disconnected!", this); if (!PhotonNetwork.ReconnectAndRejoin()) { if (PhotonNetwork.Reconnect()) { Debug.Log("Successful reconnected!", this); } } else { Debug.Log("Successful reconnected and joined!", this); } } public override void OnDisconnected(DisconnectCause cause) { StartCoroutine(MainReconnect()); } }

Steam VR and PUN Classic

$
0
0
Hey all. I've been trying to debug this for a couple days now and I have really ran into a snag. No options left but to come ask. I am finishing up a basic engine for my Multiplayer VR Game and everything is ready except for this one very odd problem: The player's hands and heads all have views and transform views, no problem there, all is well. I am using Steam VR's Interactable scripts for picking objects up. When a player goes to pick an object up, I transfer ownership of that object to the player picking it up, but then it disappears from the other player's scene (Still in hand, working as intended on the owner's screen). When the object is let go of, it reappears right where it should for both players like nothing was ever wrong. Upon further inspection, when looking in the editor, the object seems to teleport to very close to the origin of the scene just below the map and stays there. Doesn't move relative to the person holding it, just stays in one spot until the player releases it. This has become quite frustrating as it is not really breaking anything and it seems like I have just made some kind of silly oversight. I have seen similar issues on this board but their solutions didn't seem to affect my outcome. Anyone have any ideas? Thanks!

Only update OnPhotonSerializeView with PhotonTransformView

$
0
0
I've made lag compensation with OnPhotonSerializeView. My problem is that I want to sync my animations with a PhotonAnimatorView, but when i add it to my Observed Components, OnPhotonSerializeView udates even when the player is standing still, because of the PhotonAnimatorView, which results in a "InvalidCastException: Specified cast is not valid." error and an unnessecary amount of OnPhotonSerializeView udates. Is there a way i can trigger OnPhotonSerializeView with PhotonTransformView changes only?

Don't destroy local player when disconnecting

$
0
0
Hello, I follow the tuto about the manual Instantiation, and it works well. In the detail, I made this: The localplayer exist in the main scene in an offline mode (PhotonNetwork.offlineMode = true;) After connection, i spawn a remote player with a raiseevent and send PhotonID But when the player disconnect, the local player is destroy. So no more camera, interaction. How to avoid this? I try several things but don't find the right solution. So I take all tips or solution. By the way, I use manual instantiation to avoid destroying of local player between offlinemode and connect mode. Thanks advance

RPC - Null Reference Exception

$
0
0
Hi, I'm new to this forum so if I mess any formatting up please do say. :smile: Anyways, currently I'm using PUN 2.0 on Unity 2018.3.0f2 and I ran into a problem with an RPC call. The gist of what I'm trying to do is I have a plane that can bomb cars using missiles, and I need to synchronize the missiles across all clients. The way I've chosen to do this is to have the missile be unnetworked, to save some bandwidth. Instead, I use an RPC call to instantiate a unnetworked prefab of the missile on each client with the same target, speed, etc. In order to handle collision damage, the player that gets hit by it's own local missile will take that damage. The problem is, whenever I hit the key "e", the missile doesn't launch and instead this error code is produced in the console: Here's the error.
NullReferenceException: Object reference not set to an instance of an object
Photon.Pun.PhotonNetwork.ExecuteRpc (ExitGames.Client.Photon.Hashtable rpcData, Photon.Realtime.Player sender) (at Assets/Photon/PhotonUnityNetworking/Code/PhotonNetworkPart.cs:502)
Photon.Pun.PhotonNetwork.RPC (Photon.Pun.PhotonView view, System.String methodName, Photon.Pun.RpcTarget target, Photon.Realtime.Player player, System.Boolean encrypt, System.Object[] parameters) (at Assets/Photon/PhotonUnityNetworking/Code/PhotonNetworkPart.cs:1060)
Photon.Pun.PhotonNetwork.RPC (Photon.Pun.PhotonView view, System.String methodName, Photon.Pun.RpcTarget target, System.Boolean encrypt, System.Object[] parameters) (at Assets/Photon/PhotonUnityNetworking/Code/PhotonNetwork.cs:2723)
Photon.Pun.PhotonView.RPC (System.String methodName, Photon.Pun.RpcTarget target, System.Object[] parameters) (at Assets/Photon/PhotonUnityNetworking/Code/PhotonView.cs:410)
WeaponManager.Update () at Assets/Scripts/WeaponManager.cs:92
The code at WeaponManager.cs:92 is my RPC call:
photonView.RPC("LaunchMissile", RpcTarget.All);
For context, here's WeaponManager.cs:92 with surrounding code:
if (Input.GetKeyDown("e"))
        {
            if (FindClosestTarget(GetVisibleGameObjects()) != null)
            {
                Debug.Log(GetVisibleGameObjects().Count);
                // Launch missile on all clients
                Debug.Log(photonView);
                photonView.RPC("LaunchMissile", RpcTarget.All);
                AudioSource.PlayClipAtPoint(missileLaunchSound, transform.position);
        }
    }
And.. the RPC method (also in WeaponManager.cs) is:
    [PunRPC]
    void LaunchMissile(PhotonMessageInfo info)
    {
        Debug.Log(" LAUNCHING!");
        // Create Missile
        GameObject _missile = Instantiate(missile, transform.position - new Vector3(0, 4), transform.rotation);
        _missile.GetComponent().SetOwner(info.photonView);

        // Gather target and missile ids.
        //int targetViewID = FindClosestTarget(GetVisibleGameObjects()).GetComponent().ViewID;
        GameObject target = FindClosestTarget(GetVisibleGameObjects());
        //int missileViewID = _missile.GetComponent().ViewID;

        _missile.GetComponent().Fire(target);
    }
In WeaponManager.cs, photonView is referenced in the start method:
photonView = GetComponentInParent();
I've been trying to fix this for a couple days now, so any help is greatly appreciated! :smile:

How to record audio using microphone (onclick button) and store it to play it back

$
0
0
Hi, i was wondering if you were able to achive this and if you can share me your scripts. What i'm trying to do is to record audio, then to store and play it back. Thank you. I'm also using placenote so no idea if it gets more complicated. I already get the microphone working on a simple scene but not in the one with photon and placenote. Thx

Detect other player disconnect by quit app

$
0
0
Hi I just started using PUN for my unity turn base game for few weeks and I got some problem with detecting player disconnection. Scenario: 1. Two players entered a room of max 2 players 2. One player quit application 3. Check OnPhotonPlayerDisconnected callback in the class extend PunBehaviour, the log inside is not called, use PhotonNetwork.otherPlayers to check player in the room, it show 2 players still inside In order to let the same player rejoin the room, should the player leave room or just let the id keep in the room? if the player need to leave room, how to let the player disconnect and leave room when he quit the application?

Oculus Avatars setup

$
0
0
Hey, I followed this tutorial to get Oculus Avatars to worK: https://doc.photonengine.com/en-us/pun/v2/demos-and-tutorials/oculusavatarsdk I don't see my local avatar in game i.e. no hands or any indication it's loaded, on the other end on a remote client I can see my avatar but it doesn't show my personalised avatar and it doesn't follow my position if I move around locally (I use VRTK). Do I have to sync the positions separately and does the localavatar automatically attach to my scene OVRCameraRig even if I'm using VRTK which handles multiple setups? Thanks

Go + Rift avatar template: help me?

$
0
0
I have a basic template working that lets me connect Go and Rift players using PUN. The avatars are shown correctly and the hands too, and it's possible to log in with both from the same account at the same time. One current limitation is that it handles only a single scene. I'm thinking of putting this on GitHub to help other people. However I'm going to need a bit of help with testing, mostly I need to make sure I write instructions that are complete and clear. To make this work I'd need people willing to try this and tell me where the documentation was unclear, or where they ran into difficulties. If you're interested in this template, or just in helping out, please reply to this thread and let's get something organized!

Issue getting room list (called from javascript sdk)

$
0
0
I have my unity game running, and I have a player connected to a room called "Test". I have a simple function on my javascript client that asks for the room list.
public getRoomList() {
    return this.lbcc.availableRooms();
  }
It is returning nothing though. The AppId on the javascript side is 'AppVersion: '0.1.3_2.12',' The AppId on the PUN side is [SerializeField] private string VersionName = "0.1.3"; Do I have something setup wrong?

Photon Unity Networking (PUN) problem

$
0
0
Hello how can i solve this problem. It happened when I tried to build my game. "Copying assembly from 'Temp/PhotonChat.dll' to 'Library/ScriptAssemblies/PhotonChat.dll' failed"

How to include Magic Leap Lumin platform on "Photon3Unity3D.dll"?

$
0
0
The PUN plugin won't build when its imported into the Magic Leap package. It keeps saying "The type or namespace name `ExitGames' could not be found. Are you missing an assembly reference?". I did a search online and developer mentioned the problem could be solved by "including Magic Leap Lumin platform on "Photon3Unity3D.dll". Anybody know how to do this? Or is there other solutions to this problem? Thank you! Here are the specs I'm using for developing: Photon: PUN 2 Unity 2019.1.0b10 Windows 10 LuminSDK 0.20.0 LuminOS 0.95.0

Custom event cache cleanup question

$
0
0
I'm using PUN 2. I want my player objects to not destroy even when a player leaves. I looked at the docs, and they mention that I can set RoomOptions.CleanupCacheOnLeave to false. I did that, but I'm concerned that there are other things (apart from the player GameObject not being destroyed) that might get affected. For all the raised events I have in my game, if I set their RaiseEventOptions.CachingOption = EventCaching.RemoveFromRoomCacheForActorsLeft will that make sure that all the events raised by that specific player get cleaned from the cache? Also, is there any other thing I would need to worry about after setting RoomOptions.CleanupCacheOnLeave to false? Any help will be appreciated. Thanks!

Hololens sharing tutorial with PUN2

$
0
0
Hello; I've come to Photon after trying and failing to get the Mixed Reality Academy sharing tutorials and UNET tutorials to work properly with Hololens and Unity. I've scoured the internet for snippets of information and tried to piece together what I can. The description below sounds like a simple game to make, and the way I believe Photon allows a multiplayer to be built (please correct me if I'm wrong), but when it comes to deploying to Hololens, I always run into errors, so here I am to ask for your help! 1) I want to make a Hololens-based multiplayer game where one person is the server / host, and others can join the game 2) The host can move objects / prefabs / 3D models in different scenes 3) The others should be able to see what the host is doing, but they don't have to interact with them or the objects (if they can without much extra work, then that's a bonus) 4) The others can leave the game when they like 5) When the host ends the game, everyone else leaves the game I am building with: - Holotoolkit 2017.4.3.0 because if I build with Mixed Reality Toolkit I get other errors with other parts of my game and its SDKS - Unity 2017.424f1 because this has been the most stable for the above reason too - PUN2 I have followed the PUN Basics tutorial and successfully got it to work on PCs and the Unity editor between 3 computers. I get errors such as:
Plugin 'Photon3Unity3D.dll' is used from several locations:
 Assets/Photon/PhotonLibs/Photon3Unity3D.dll would be copied to /Photon3Unity3D.dll
 Assets/Photon/Photon3Unity3D.dll would be copied to /Photon3Unity3D.dll
Please fix plugin settings and try again.
Plugins colliding with each other.
Then I try deleting some of the .dll files (as suggested by another forum post, and then I can build to PC, but when building to Hololens, I get these errors, and yet it also tells me it's built with a result of "Succeeded":
Reference rewriter: Error: type `System.Security.Cryptography.HMACSHA256` doesn't exist in target framework. It is referenced from Photon3Unity3D.dll at System.Boolean ExitGames.Client.Photon.EncryptorManaged.Decryptor::CheckHMAC(System.Byte[],System.Int32).
UnityEngine.Debug:LogError(Object)
PostProcessWinRT:RunReferenceRewriter() (at C:/buildslave/unity/build/PlatformDependent/MetroPlayer/Extensions/Managed/PostProcessWinRT.cs:989)
PostProcessWinRT:Process() (at C:/buildslave/unity/build/PlatformDependent/MetroPlayer/Extensions/Managed/PostProcessWinRT.cs:211)
UnityEngine.GUIUtility:ProcessEvent(Int32, IntPtr)
And others such as System.Void System.Threading, Socketflags, etc. I then take my "successful" Hololens build into Visual Studio in order to deploy to the Hololens, but then get these errors:
Severity	Code	Description	Project	File	Line	Suppression State
Warning	CS0618	'ApplicationView.SuppressSystemOverlays.set' is obsolete: 'Use the TryEnterFullScreen method and IsFullScreenMode property instead of SuppressSystemOverlays. For more info, see MSDN.'	Photon_test	D:\Unity Projects\Photon_test\Builds HL\Photon_test\App.cs	56	Active
Severity	Code	Description	Project	File	Line	Suppression State
Error		The command ""D:\Unity Projects\Photon_test\Builds HL\Unity\Tools\AssemblyConverter.exe" -platform=uap -lock="D:\Unity Projects\Photon_test\Builds HL\Photon_test\project.lock.json" -bits=32 -configuration=Release -removeDebuggableAttribute=False -uwpsdk=10.0.17763.0 -path="." -path="C:\Program Files\Unity\Hub\Editor\2017.4.24f1\Editor\Data\PlaybackEngines\MetroSupport\Players\UAP\dotnet\x86\Release" "D:\Unity Projects\Photon_test\Builds HL\Photon_test\UnityEngine.TerrainModule.dll" "D:\Unity Projects\Photon_test\Builds HL\Photon_test\UnityEngine.StyleSheetsModule.dll" "D:\Unity Projects\Photon_test\Builds HL\Photon_test\UnityEngine.TerrainPhysicsModule.dll" "D:\Unity Projects\Photon_test\Builds HL\Photon_test\UnityEngine.TilemapModule.dll" "D:\Unity Projects\Photon_test\Builds HL\Photon_test\UnityEngine.TextRenderingModule.dll" "D:\Unity Projects\Photon_test\Builds HL\Photon_test\UnityEngine.SpriteShapeModule.dll" "D:\Unity Projects\Photon_test\Builds HL\Photon_test\UnityEngine.PhysicsModule.dll" "D:\Unity Projects\Photon_test\Builds HL\Photon_test\UnityEngine.Physics2DModule.dll" "D:\Unity Projects\Photon_test\Builds
(I can't add all the code above because I've gone over my character limit!) Any suggestions or help would be wonderful; I have been stuck on networking and sharing for a long time, but it seems it's not an easy task either! Thanks in advance! Sarah

Can't instantiate with CustomProperties

$
0
0
Yosh! First time using Photon, I have already make an online playable version of my game, and now I want to improve menu and game mode and all that stuff! So I can choose a team side, Team A, or Team B, when I instantiate my player (the Master) there is no problem, all is setting good, but for the next player, nothing is working! I can see I have access to CustomProperties, and when the other player is instantiate, everything is good EXCEPT the custom properties is always set AFTER my other player is instantiate! here is the fonction call at the "Start" of the prefab player : public void InitTeam() { eTeam team = eTeam.None ; if (GetPhotonView().IsMine) team = (eTeam) PhotonNetwork.LocalPlayer.CustomProperties[SDMOGameSettings.PLAYER_TEAM]; else { foreach (var p in PhotonNetwork.PlayerList) { if (p.UserId == GetPhotonView().Owner.UserId) { team = (eTeam) p.CustomProperties[SDMOGameSettings.PLAYER_TEAM]; break; } } } Debug.Log("Team init : " + team); m_Team = team; m_SpawnPoint = eSpawnPoint.A; Init(); } and here is the way I instantiate players : private void SpawnPlayer() { var spawnManager = SDMOGameplay.SpawnManager.GetInstance(); if (spawnManager == null) return; //var spawnPoint = spawnManager.GetAvailableSpawnPoint((int) PhotonNetwork.LocalPlayer.CustomProperties[SDMOGameplay.SDMOGameSettings.PLAYER_TEAM], (int) SDMOGameplay.eSpawnPoint.A) ; var player = PhotonNetwork.Instantiate("PlayerNew", Vector3.zero, Quaternion.identity, 0); m_MyPlayer = player.GetComponent(); m_MyPlayer.SetControllable(false); SDMOGameplay.GameManager.GetInstance().SetMyPlayer(m_MyPlayer); Hashtable props = new Hashtable { {SDMOGameplay.SDMOGameSettings.PLAYER_INSTANTIATE, true} }; PhotonNetwork.LocalPlayer.SetCustomProperties(props); } I'm on this problem since a week, so came here for some help! Thx

Having problem to create rooms using one single build Unity 5.6 - standlone

$
0
0
The plugin that I am currently using in the project does not allow me to create more than 1 room in a single build. I am using the basic photon PUN. Is there any way for me to solve this issue? My game is working with Photon but for some reason I cannot create multipe rooms in one single build standlone. Please help me...
Viewing all 8947 articles
Browse latest View live


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