my instantiated button will not instantiate a prefab when clicked. i am new to pun and i am trying to get an instantiated button to instantiate an object when clicked. the error i get is "missing prefab reference". i have it assigned in the inspector and when the game is running i can drag and drop the script to the button onclick and it will work. i dont understand why it wont do it without the drag and drop. here is my code. thanks in advance.
// so it will show in the inspector
[SerializeField]
private Button beginButton;
void Start()
{
// i assign it as a game object because i was having trouble not seeing it when the game was running
// so i did this and it becomes a child of the canvas and can be seen and clicked.
GameObject BB = PhotonNetwork.Instantiate(this.beginButton.name, new Vector3(200f,650f,0f),
Quaternion.identity, 0) as GameObject;
BB.transform.SetParent(canvas.transform);
}
↧
my instantiated button will not instantiate a prefab when clicked
↧
Weapon Shooting
Hello, I haven't found any answers to this question nor videos on the internet. But I am currently setting up weapon shooting for my co op zombie survival game and I am having issues with syncing the weapon shooting through the network.
Now, the weapon shooting itself works fine. It's just that I don't understand how Photon works and all the animations and effects are not visible for other players. For the players and the zombies I use PhotonView so they are visible for every player. The zombies are fully setup, they target the closest player and are functioning very smoothly and well through the network. It's just that when player 1 shoot I want player 2 to see the shooting animation, the muzzle flash and the impact effect. I have a script attached to the weapon prefab that is instantiated to the player's "Weapon Holder" parent. I was just wondering if I would have to instantiate every single effect using PhotonNetwork.Instantiate.
I tried instantiating the weapon through the Network but that instantiated the weapon into the player's weapon holder parent and also it instantiated one more into the center of the world. This also lead to it so that players that joined later don't see the weapons that the players that joined before have equipped. So in this case if I join after the host, the host won't have a weapon on that player's screen.
I know that this is a super confusing question. I don't care I'm pissed off because I've spent all day try to figure this out and this doesn't work. Please answer this question with a video or documentation on how to sync this. I don't want to give up on this project.
Thanks
↧
↧
LAG new version pun 2 (photonhandler.fixedupdate) and (logStringToConsole)
please help

↧
interactable buttons - Help
Hi, i made some buttons that work very good on client side, but as soon as another player joins the server side kicks in and it doesn't work anymore. Iam trying to send a ray from the player if they left-click and when they do i save if that ray hits anything. If it hits something with the tag "button" i want that button to its thing. I thinking long term if i want to implement more buttons i can't have a switch case for every button in the game right?
Any answer is appreciated
Picture of the code.
https://i.gyazo.com/e8de1842f0edf3d45d1a4689a2434760.png
↧
[PUN2] Interest group not work
Hello,
I am a new user of Photon Voice 2. I tried to create voice groups between players, then in order to test I built 3 versions of the game adding the following code in the Start method of a new script attached to the players where the use case is:
Players with interest group 1 can listen between them
Players with interest group 2 can listen between them
Everybody can listen to players with interest group 0
Players with interest group 1 cannot listen to players with interest group 2 and vice versa
The first version have this code:
Player 1: #Unsuscribe from 1 PhotonNetwork.SetInterestGroups(new byte[0] { 1 }, null); #Unsuscribe from 2 PhotonNetwork.SetInterestGroups(new byte[0] { 2 }, null); #Suscribe to 1 PhotonNetwork.SetInterestGroups(null, new byte[0] { 1 });The second version have this code:
Player 2: #Unsuscribe from 1 PhotonNetwork.SetInterestGroups(new byte[0] { 1 }, null); #Unsuscribe from 2 PhotonNetwork.SetInterestGroups(new byte[0] { 2 }, null); #Suscribe to 2 PhotonNetwork.SetInterestGroups(null, new byte[0] { 2 });The third version doesn't have any code, this version is for Player 3 with InterestGroup zero. Then I connect to the same room and realize the test: Player 1 and Player 2 can listen Player 3. (That's expected because everybody listen to zero) Player 2 can listen to other Player 2. (That's expected) Player 1 can listen to other Player 1. (That's expected) Player 1 can listen to Player 2. (That's not expected because they belong to different interest groups) I can't figure out how to solve this problem. After searching, I found this: https://forum.photonengine.com/discussion/14829/interest-group-does-nothing There, @JohnTube said a line of code was missing but even adding that line the program doesn't have the expected test between interest groups. I don't know how to fix this or if @Slyp found a workaround. I can share my project if necessary.
↧
↧
Gameobject name is not changed for all clients
Hi, I want to instantiate some objects over the network and change its name. I instantiate them but the name is not changed for clients. here is my code :
[PunRPC]
private void RPC_InstantiateObjects()
{
var bus = PhotonNetwork.InstantiateSceneObject(Path.Combine("Network", "Magistrala"), new Vector3(-0.259f, 0.5971f, -2.167f), new Quaternion(0, 90, 90, 0), 0);
var tablet = PhotonNetwork.InstantiateSceneObject(Path.Combine("Network", "TabletaDisplay"), new Vector3(-0.5f, 0.5902f, -2.167f), new Quaternion(0, 90, 90, 0), 0);
int index = bus.gameObject.name.IndexOf("(");
if (index > 0)
bus.gameObject.name = bus.gameObject.name.Substring(0, index);
int index2 = tablet.gameObject.name.IndexOf("(");
if (index2 > 0)
tablet.gameObject.name = tablet.gameObject.name.Substring(0, index2);
RandomTablet();
}
And here I call the method:
public override void OnJoinedRoom()
{
if (PhotonNetwork.IsMasterClient)
{
PV.RPC("RPC_InstantiateObjects", RpcTarget.All);
}
}
Has anyone any idea why the name is not changed for clients ?
↧
photon broken.
(redoing post again because CLEARLY nobody is awnsering to my past post)
i have 4 bugs.
first character animation is bugged in a weird way, i can move in the build but my friends player model decides to go to move forward animation when im moving or copy my animations when im moving, when my friends moving he has no animation (just idle animation) and then to him he sees my player model animation doing the exact same thing like it happened to him.
second bug, weapons wont do anything, knife and weapons wont do anything, the gun wont change or shoot in the game, like first person can shoot but player model has the guns in it and has a script called WeaponSync.cs and it not doing anything, i cant even kill with rpg, grenade and grenade launcher.
third bug player FallDamage is not doing anything, when i fall from a great high in game i suppost to die and spawn broken legs ragdoll but instead it does no damage, only sound, theres no bloody screen, just fall sound, but with explosive damage it doesnt do anything too, with bone damage i get only this error PhotonView with ID 1001 has no method "BoneDamage" marked with the [PunRPC](C#) or @PunRPC(JS) property!, even tho im using PunRPC and not RPC.
forth bug. character skin is not working correctly, my cloth skin is all black when it suppost to be green
Scripts:
Player damage (Shows parts only of the damage not doing anything)
public void ExplosiveDamage(float explosiveDamage)
{
GetComponent().clip = RPGHIT;
GetComponent().Play();
if (disableDamage)
return;
fadeValue = 2;
photonView.RPC("ApplyRocketDamage", PhotonTargets.All, explosiveDamage, PhotonNetwork.player);
}
[PunRPC]
//This is damage sent fro remote player instance to our local
void DoRpgDamage(float explosiveDamage, PhotonPlayer player)
{
if (weKilled)
return;
if (currentHp > 0 && photonView.isMine)
{
this.StopAllCoroutines();
StartCoroutine(doCameraShake());
}
fadeValueB = 2;
currentHp -= explosiveDamage;
//We got killed
if (currentHp < 0)
{
//Deactivate all child meshes
for (int i = 0; i < transform.childCount; i++)
{
transform.GetChild(i).gameObject.SetActive(false);
}
//Spawn ragdoll
GameObject temp;
temp = Instantiate(goryRagdoll, transform.position, transform.rotation) as GameObject;
if (!photonView.isMine)
{
temp.SendMessage("clearCamera");
if (PhotonNetwork.player == player)
{
//Send death notification message to script WhoKilledWho.cs
networkObject.SendMessage("AddKillNotification", gameObject.name, SendMessageOptions.DontRequireReceiver);
//Add team score
int teamScore = new int();
if ((string)PhotonNetwork.player.customProperties["TeamName"] == rmm.team_1.teamName)
{
//Add 1 kill for our player
int totalKIlls = (int)PhotonNetwork.player.customProperties["Kills"];
totalKIlls++;
Hashtable setPlayerKills = new Hashtable() { { "Kills", totalKIlls } };
PhotonNetwork.player.SetCustomProperties(setPlayerKills);
}
if ((string)PhotonNetwork.player.customProperties["TeamName"] == rmm.team_2.teamName)
{
teamScore = (int)PhotonNetwork.room.customProperties["Team1Score"];
teamScore--;
Hashtable setTeam1Score = new Hashtable() { { "Team1Score", teamScore } };
PhotonNetwork.room.SetCustomProperties(setTeam1Score);
//Add 1 kill for our player
int totalKIlls = (int)PhotonNetwork.player.customProperties["Kills"];
totalKIlls++;
Hashtable setPlayerKills = new Hashtable() { { "Kills", totalKIlls } };
PhotonNetwork.player.SetCustomProperties(setPlayerKills);
}
}
}
else
{
//print ("We got killed");
temp.SendMessage("RespawnAfter");
//We was killed, add 1 to deaths
int totalDeaths = (int)PhotonNetwork.player.customProperties["Deaths"];
totalDeaths ++;
Hashtable setPlayerDeaths = new Hashtable() { { "Deaths", totalDeaths } };
PhotonNetwork.player.SetCustomProperties(setPlayerDeaths);
//Destroy our player
StartCoroutine(DestroyPlayer(0.2f));
if (PhotonNetwork.player == player)
{
//Our player fell down
networkObject.SendMessage("PlayerFellDown", PhotonNetwork.player.name, SendMessageOptions.DontRequireReceiver);
teamLives = (int)PhotonNetwork.room.customProperties["Team1Score"];
teamLives--;
Hashtable setTeam1Score_fell = new Hashtable() { { "Team1Score", teamLives } };
PhotonNetwork.room.SetCustomProperties(setTeam1Score_fell);
}
}
currentHp = 0;
weKilled = true;
}
}
↧
JoinRandomRoom isn't random?
I'm pretty new to Photon (PUN) so I'm sorry if I'm just missing something :s but whenever I set up two rooms, and get a bunch of clients to join them via PhotonNetwork.JoinRandomRoom() they all preferencially join one room first.
Now this may just be my terrible luck but I've run the test a few times and it seems like all the clients will attempt to fill one room before the other. A particular case I tested to further prove this precidence in room choice is to fill the first room, let the remaining clients start joining the second room, and then if I clear up some space in the first again it regains its priority and is filled full again before the second.
It looks like maybe it works off of a randomly ordered list and fills from the first rooms to the last...? I've tried it both in and out of a Lobby (e.g. via JoinLobby()) and that didn't seem to change anything.
Am I doing something wrong here? Is it just not really random? Or is my luck so bad that it looks like it isn't random :p
Thankyou for taking your time to read this! I'm looking forward to learning more about PUN and appreciate any help I can get.
↧
Photon Refreshing Authentication Token
Hi guys, I have a problem with a project. I have a server like application in Unity. The app is always connected to the Master Server and to lobby. It is checking if a new room has been created and joins to it. The problem is the time between game rooms may vary and after a certain amount of time waiting in lobby, I can not join a room. It says authentication token is expired and I disconnect and reconnect to the master server/lobby to get a new token.
I made some research and saw some posts about raising events/RPC's periodically but I am not in a game room and I believe I can not raise events etc. in lobby.
How can I refresh my authentication token or stay active in the lobby so my token won't get expired?
↧
↧
Join room in specific lobby
I joining lobby with
TypedLobby lobby = new TypedLobby("*", LobbyType.Default);
PhotonNetwork.JoinLobby(lobby);
and then joining room with PhotonNetwork.JoinRoom(**);
But Photon does not join lobby, is there a way to join room in specific lobby or better way to join lobby?
↧
Gameobject name is not synchronized over the network
Hi,
I want to instantiate some objects over the network and change its name. I instantiate them but the name is not changed for clients. here is my code :
[PunRPC]
private void RPC_InstantiateObjects()
{
var bus = PhotonNetwork.Instantiate(Path.Combine("Network", "Magistrala"), new Vector3(-0.259f, 0.5971f, -2.167f), new Quaternion(0, 90, 90, 0), 0);
RPC_tablet = PhotonNetwork.Instantiate(Path.Combine("Network", "TabletaDisplay"), new Vector3(-0.5f, 0.5902f, -2.167f), new Quaternion(0, 90, 90, 0), 0);
int index = bus.gameObject.name.IndexOf("(");
if (index > 0)
bus.gameObject.name = bus.gameObject.name.Substring(0, index);
int index2 = RPC_tablet.gameObject.name.IndexOf("(");
if (index2 > 0)
RPC_tablet.gameObject.name = RPC_tablet.gameObject.name.Substring(0, index2);
RandomTablet();
}
And here is where i call that method:
public override void OnJoinedRoom()
{
if (PhotonNetwork.IsMasterClient)
{
PV.RPC("RPC_InstantiateObjects", RpcTarget.All);
}
}
Has anyone any idea why the name is not changed for clients ?
↧
Unregister PhotonView locally
Hello !
I'm currently facing a problem concerning the photonView component.
Here's my situation : Classic behaviour, I have 1 master and 2 clients (clientA and clientB) in a room. They all load a Game Scene when the master hits Play. In the scene I have a GameManager containing an Awake callback. In this callback, the 2 clients use the PhotonNetwotk.Instantiate(playerPrefab) function to instantiate their character. Their character own a Camera gameObject with a photonView on it. I'd rather delete locally clientB's camera on the clientA's application and vice versa, in order to avoid issues with multiple cameras. To do this, I use the MonoBehaviour.Destroy(cameraGO).
Here's my issue : Every time the cameraGO of the clientB is updated, the clientA still receives this modification in the form of a warning : Received OnSerialization for view ID XX. We have no such PhotonView!
This probably does not cause any issue yet, but I don't think that it's a clean situation for the application (stream flood, may cause some Timeout ?).
What I tried : I tried to call the function PhotonNetwork.LocalCleanPhotonView() but with no success (both before and after destroying the gameObject).
So is there any clean way to 'unregister' the callbacks from a photonView that still exist on the server but not locally ?
Thanks.
↧
(bug) Random matchmaking does not work with OnePlus 6t, but with every other device
I have an really odd problem regarding random matchmaking using the example code from https://doc.photonengine.com/en-us/realtime/current/lobby-and-matchmaking/matchmaking-and-lobby
I use this part to join a room:
ExitGames.Client.Photon.Hashtable expectedCustomRoomProperties = new ExitGames.Client.Photon.Hashtable() { { "map", 1 } };
PhotonNetwork.JoinRandomRoom(expectedCustomRoomProperties, 4);
And this to create a room;
RoomOptions roomOptions = new RoomOptions();
roomOptions.CustomRoomPropertiesForLobby = new string[] { "map", "ai" };
roomOptions.CustomRoomProperties = new ExitGames.Client.Photon.Hashtable() { { "map", 1 } };
roomOptions.MaxPlayers = 4;
PhotonNetwork.CreateRoom(null, roomOptions, TypedLobby.Default);
It works when two of these tested devices create/search for a room (they are finding each other)
galaxy s10
galaxy note 10
galaxy s8
Unity Editor
Old galaxy tab 3
Old xperia
Android emulator "Memu"
It does not work on the OnePlus 6t from a friend. The OnePlus can create its own room and join it. If I remove random matchmaking and go for a static name like "Room123" the OnePlus finds the other players and everything works great. But it seems like it just cant find other players rooms with random matchmaking and filters. The game is a 2D realtime Multiplayer, nothing complex. Is this a known issue? Is there any chance to fix it?
I would be thankful for any help.
↧
↧
Photon view id became 0 and RPC not found when the gameobject was made as prefab
I m using unity 2019.1, A two player multiplayer game
everything was working fine when the gameobject was just a empty gameobject in the scene
It had view id.
I made that empty gameobject a prefab, where photonView is attached and Rpc function script is attached.
Now the prefab shows the view id as "SET AT RUNTIME". And in the run time when prefab is spawned and then the View ID shows as 0 and It pops up error saying View ID is 0 and RPC not found
↧
Photon connection problem in US region.
We're working (in Asia) on a multiplayer game using photon version 2 with Unity 2019.2.11f1, the game is working fine in region Asia but our client is located in USA and some of our players from 'us' region are unable to connect, and some of the players get kicked out automatically after joining the game. Any help is appreciated. Thanks.
↧
Adding developers to the dashboard
Hello everyone! Probably this is a very simple and stupid question but, how can I add other developers to the PUN dashboard? I don't seem to find the place for that, and I don't want to share the admin mail password with everyone.
Thank you all!
↧
Regarding playing with friends
Hi,
I want to add an option play with friends using GameCenter and Facebook. What is the best way using photon unity networking ?
My requirements are
Add player as a friend via GameCenter and Facebook
Player can accept add invites.
Should see players online
Should know the connected server.
Can photon unity provide these functionality?
I want to add an option play with friends using GameCenter and Facebook. What is the best way using photon unity networking ?
My requirements are
Add player as a friend via GameCenter and Facebook
Player can accept add invites.
Should see players online
Should know the connected server.
Can photon unity provide these functionality?
↧
↧
Photon Self Hosted Server Without Internet[LAN]
We are trying to self host the photon server sdk to connect multiple user through local network without internet. Is there a possibility in connecting users into the server through local network.?
↧
Network objects destroyed when having a quick disconnection
Hello !
I came across a problem when starting to handle quick disconnections in my application.
Here's my situation : I have 1 master and 2 clients (clientA and clientB) which all have their own character prefab instantiated on the network. I have set a playerTTL to 60000 in my room options. I frequently have some quick disconnections because of Client Timeout issues (mainly caused by Reliable events not received I guess). Those quick disconnections trigger the OnLeftRoom and OnDisconnected PUN callbacks, but most important, all network objects are destroyed locally (in the client's application).
Here's my issue : Having all the network objects destroyed and then re-instantiated only because of a quick disconnection leads to undesirable behaviour.
What I've done : I only simulated disconnections by calling PhotonNetwork.Disconnect() through an input. I will try to use the Photon Lag Simulation Gui tool later.
Is there any settings that I'm missing that could keep the network objects alive, or is it an
unchangeable PUN behaviour ?
Thanks !
↧
[PUN2]When Connect Chinese Mainland, Photon Update local value to GUID
My code that set CustomAuth below.
==========================================================
var customAuth = new AuthenticationValues { AuthType = CustomAuthenticationType.Custom };
customAuth.AddAuthParameter("username", ACD1B613D096472);
customAuth.AddAuthParameter("token", PhotonCustomAuthenticationToken);
PhotonNetwork.AuthValues = customAuth;
==========================================================
When i connect other server, I see UserId is ACD1B613D096472 in room.
But when in Chinese Mainland, I see UserId is f9ec65af-a01b-46c2-8933-ed64b02d1f48 in room.
I use PlayFab UserID to set customAuth For finding friend, checking player game result so on.
This cause an error in my game logic.
How do I deal with this?
Version - Pun: 2.5 Photon lib: 4.1.2.4
Unity log below.
==========================================================
Received your UserID from server. Updating local value to: f9ec65af-a01b-46c2-8933-ed64b02d1f48
UnityEngine.Debug:Log(Object)
Photon.Realtime.LoadBalancingClient:DebugReturn(DebugLevel, String) (at Assets/Photon/PhotonRealtime/Code/LoadBalancingClient.cs:1834)
Photon.Realtime.LoadBalancingClient:OnOperationResponse(OperationResponse) (at Assets/Photon/PhotonRealtime/Code/LoadBalancingClient.cs:1942)
ExitGames.Client.Photon.PeerBase:DeserializeMessageAndCallback(StreamBuffer) (at C:/Dev/photon-sdk-dotnet/PhotonDotnet/PeerBase.cs:615)
ExitGames.Client.Photon.EnetPeer:DispatchIncomingCommands() (at C:/Dev/photon-sdk-dotnet/PhotonDotnet/EnetPeer.cs:553)
ExitGames.Client.Photon.PhotonPeer:DispatchIncomingCommands() (at C:/Dev/photon-sdk-dotnet/PhotonDotnet/PhotonPeer.cs:1428)
Photon.Pun.PhotonHandler:FixedUpdate() (at Assets/Photon/PhotonUnityNetworking/Code/PhotonHandler.cs:130)
==========================================================
↧