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

Sending data when Player properties changes

$
0
0
So lately i've been trying to work on weapon switching,
what i did is that i made the player change the weapon locally first (offline), then i change the player Custom Properties which is "currentWeapon" to the weapon index in the array and then in the server i used the Callback method (OnPhotonPlayerPropertiesChanged) to send the weapon index of the player who switched the weapon to all players
I'm still trying to figure out a way if you can help me out with an idea to send all players the function weapon switch as an RPC.. Thanks :)

here's the code:
void Start()
{
WeaponHash = new Hashtable() { { "currentWeapon", Array.IndexOf(Weapons, currentWeapon) } } ;
PhotonNetwork.player.SetCustomProperties( WeaponHash );
}

void SwitchWeapon(PlayerWeapon weapon)
{
//PhotonNetwork.player.SetCustomProperties()
foreach (PlayerWeapon w in Weapons)
{
if(weapon != w)
{
w.gameObject.SetActive(false);
}
else
{
WeaponHash["currentWeapon"] = Array.IndexOf(Weapons,weapon);

if(PhotonNetwork.player.IsLocal)
{
PhotonNetwork.player.SetCustomProperties(WeaponHash);
}

currentWeapon = weapon;
weapon.gameObject.SetActive(true);
}

}
}


void OnPhotonPlayerPropertiesChanged(object[] hash)
{
PhotonPlayer player = hash[0] as PhotonPlayer;
Hashtable data = hash[1] as Hashtable;

if (player.ID == PhotonNetwork.player.ID)
return;
Debug.Log(Weapons[(int)data["currentWeapon"]].name);
//SwitchWeapon(Weapons[(int)data["currentWeapon"]]);
}

Update for V1.84 (ERROR)

$
0
0
After updating Photon, every time I use PhotonNetwork.Instantiate it creates GameObject and at the same time destroys the same.
What is the solution to this problem?

How to switch Room in already playing Game?

$
0
0
I am making a social game ,it has a private room and lobby room.
The private Room only player himself can visit it.
I am new programmer.I don't know how to switch Room in Playing Game(in already connected game)。
Need I Use PhotonNetwork.ConnectUsingSettings("2"); again to enter a new room?

InRoomRoundTimer

$
0
0
Hi guys,

I don't see InRoomRoundTimer.cs in PUN version(v1.84.1) that I download (this file should be on Photon Unity Networking/UtilityScripts folder). You are deleted this file, or, there is some other problem?

Hashtable implemented in multi-scenes scenario?

$
0
0
Hi all,

I am implementing Hashtable into multi-scenes scenario, and it's not working for me. I wonder if anyone has any ideas? I am able to make Hashtable work if it's just a single scene situation, but not when need to load to the second scene.

My setup is that there a script that contains hashtable generation and properties (let's call it script A.cs), then it's been used as a class for other objects to inherit from. E.g. there's an icon to trigger on/off an object. I write a new C# script (script B.cs) that inherit the class from A.cs. The hashtable is generated when it's OnJoinRoom().

Any ideas?

Thanks.
Thomas

OnPhotonSerializeView with the Scene as the object owner

$
0
0
Does OnPhotonSerializeView write to the stream if the owner of the object is the Scene, or is it the Master Client who instantiated it? If it is written to when the owner is the Scene, which client is it writing from?

Recommended tools/approaches to prevent pirated clients from taking up CCUs?

$
0
0
Hi,

I can accept that my game might get pirated and that the offline mode will be playable, but how can I prevent pirated/cracked versions of my game from accessing PUN and taking up CCUs for my app?

Would a backend service like Playfab help? Is there an effective way to prevent pirated clients from using the network without a service external from PUN?

Any recommended tools/approaches? I just want to know if this a commonly solved problem that has existing material on the subject that I can start from.

Thanks!

Cloning a Photon Game object in the scene

$
0
0
My requirement is simple. I want to duplicate a gameobject that has an attached PhotonView component. But I'm unable to do so due to duplicate View IDs. As soon as I am instantiating this object, I am getting this error, "PhotonView ID duplicate found: Maybe one wasn't destroyed on scene load?! " . But i want a copy of this object without PhotonView Component. Can anyone help.

In regards to animator.Play()

$
0
0
Hey i am having a little trouble, I understand that i can SendNext parameters for animators however, When it comes to playing an actual animation with Animator.Play("Punch") for example. I am at a lost. If someone would point me in the right direction i would be very grateful.

multi players game & database

$
0
0
I am about to start a network game project with Unity & photon. Unfortunately I am new to network programming.
This game is about multi players fighting in the room and 10 clients at the most can join in. If you have more clients, then you need to make new room. And I'd like to manage clients info using database, such as id, status, items and so on.
PUN is for this kind of game, I guess. But how can I handle the clients info? I have some questions about this.
- Can I make my own database (ex: php & MySQL) in Photon server?
- Does Photon server support those tools? (ex: php & MySQL)
- If so, what is the price for it (server hosting for database) ?
- Does Photon already have database service which is easy for users to use ?
- Does PUN support Login service thru FB / Google?

I think these are very basic and simple questions. But I am new and not familiar with English.
Please give me detailed answers. Thanks.

[BugReport] Failed initial connection problem

$
0
0
If Photon fails to connect at the beginning, OnFailedToConnectToPhoton() is called but PhotonNetwork.connecting remains stuck as true. We display the status based on these flags and it is misleading. The status does not appear to time out within reasonable time. Anyone should be able to reproduce this by simply disconnecting from the internet and attempting to connect to Photon cloud.
I just updated to the latest PUN free version from the asset store (1.84.1) and noticed it.
Let me know if you need more information!

How to recive rpc whether the player having only the player's name

$
0
0

Hello! I'm trying to implement a private chat. I have an inputField in which I enter the name of the required player. While sending a message, I need to check whether this player is online, how do I do this? Thank you all!

I use:


var playerList = from p in PhotonNetwork.playerList select p; foreach (var player in playerList) { if (player.NickName == name) { PhotonView.Get(NEED HELP).photonView.RPC("givePrivateMessage", PhotonTargets.All, text, PhotonNetwork.playerName, false); } }


I do not know how to call rpc from the player I need...

Sorry my english...

why is my RPC not being called locally

$
0
0
Hi there,

I have this RPC method and It's not being called locally!

Console says it's sending RPC to all or player, however it returns nothing... not even an error.

Yes I am running Photon Debug in full.

Here's the method:

public static void AddMonster(GameObject monster)
{
// Add the monster to remote players lists
ScenePhotonView.RPC("AddedMonster", PhotonTargets.All, monster);
}

[PunRPC]
void AddedMonster(GameObject monster)
{
monsters.Add(monster);
}

Are remote photon views instantiated after OnJoinedLobby is called?

$
0
0
I tried adding all GameObjects of a particular tag to a list in OnJoinedLobby. Unfortunately it doesn't find anything. I'm assuming this is because the remote objects aren't actually instantiated in the local scene until sometime after the player has joined the lobby...

Is this true?

What's the best way I can add some GO's to a list for a client who has just arrived to the room? Or is this fundamentally bad design?

Cheers!

Group room and set Up

$
0
0
Hi everybody !

There is a way to "group" room of the same scene? i have multiple scene and i don't want that player of scene 1 join room with player on scene 2 :/
i'm talking about in case that roomX is full and player join a second room ^^'

And i have a last question;
What is happening if the room if full? i have to use callback like : Onmaxplayer ect...?

Thx for you're help! Have a good day !

PUN - Room Creation

$
0
0
Hi,

We have requirement in which we have to individually send message to some other user and play game with him. One work around is each user creates its own room. Let say user A and B creates two rooms A and B. User A sends message to B, user B acknowledged that message and leaves his room and join room A. After that they're in same room and they can perform operations required for game play.

We have read in forums that room creation is costly operation, we should choose some other option. Please provide detail on this, in case if its really costly operation then what are the alternatives to solve this problem. Thanks.

Get room list when inside room, Using another peer

$
0
0
Hey, I'm making a game where instead of the lobby you immediately connect to a room which is like your hang out place and you can invite friend and all that.
But i want the person to be able to browse the room list when inside his room.
I read somewhere that this can be achieved by using 2 peers. I don't care about the player count, so this seems like a good idea.

I got a peer running by doing:
peer = new PhotonPeer(ConnectionProtocol.Udp);
peer.Connect(PhotonNetwork.ServerAddress, "VariationC");

and in the update
if(peer.PeerState == PeerStateValue.Connected)peer.Service();

But i don't know where to go from there. Any help appreciated

Unity - Synchronization problem

$
0
0
Hi. I develop online soccer shooting game with with using Photon Network. Two players, will be goalkeepers respectively and will shoot each other.
For example:
Player A: Shooter
Player B: Goalkeeper

Players will change after player A shot the ball. So it will be like this:
Player A: Goalkeeper
Player B: Shooter

The goalkeeper and the shooter objects are already on stage and attached PhotonView component(I do not instantiate later these objects). At first; Player who created the room is shooter and other player is goalkepper. The problem starts here.
Local players can move their own objects(goalkeeper and shooter object) but there is a problem on global.The first player(Shooter) is can do it moving the Shooter object on local but other player sees the shooter object still(stationary). But second player(goalkeeper) when move the goalkeeper, The first player can see it. So, the first player's movements are not synchronized. There is no problem in the second player.
When I look at the photonview component of the Shooter object from the editor, I saw "Owner" value is "scene" in the local and global(Same object ama in the other player game). I think this is the problem. Because when I look at the photonview component of the goalkeeper object, I saw the owner is other player photon player name..

Sometimes this is the exact opposite(no problem in the first player but the second player has problem).

Could you help me? Thanks
Note: I am using Unity3D Game engine
(Sorry for my bad english)

Can you have multiple games on one photon account.

$
0
0
I'm super newbie to this stuff and this question probably doesn't make much sense or is super obvious. But i want to test out the free photon on a game I've made and am planning on making a new game with photon but i don't want to waste my account with the game i'm just testing with. Is there a way to switch projects being used by a certain subscription?

Send multiple data via RPC to limit message on Photon Cloud

$
0
0
Hi every body !

I would like to know if it's possible to sent multiple data with RPC?

I'm working on a 2d game like a mmorpg on Android, and i have done a little system to movement and send RPC to know the movement of other player. it's working but sometimes the exact position can change and i need to send the new position to lerp to this position in the same time than other RPC. but i'm very limited about the number of message send/s

I know how RPC is working, but at this moment i'm only use to send one INT, or string.

I want to send 2 int in the same method in one RPC, or a int with a vector 2.

So if someone can tell me if that is possible and how can i do i'll really appreciate ! :)

Thx a lot, and have a good day ! :)
Viewing all 8947 articles
Browse latest View live


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