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

Start level with all network players at the same time

$
0
0
Hello,

I searched everywhere and can't find an answer.

What is the best way to start a level with all network players at the same time? All the examples have players popping in whenever. I need to wait for players and then start a race on the level loaded.

Do you do this with the unity time or is there a photon function that syncs that information?

Thanks,
Dennis

Not able to sync colors on a small 2d app/game.

$
0
0
Hey, Im making a small 2d game and I used this script to change colors using UI buttons. I'm getting the "Object Referance not set to an instance error" at line 86,90,94 and 98. Any help would be great !

Room is still visible when it should not

$
0
0
Hi everyone,

First of all I would like to thank the whole Exitgames team for this wonderful and powerful Unity plugin which is PUN.

We are however stuck on an issue we cannot find a solution of:
A room that has been set NotVisible is still retrieved by other players inside the lobby.

This is our code:

1. Masterclient set the room IsVisible = false when max number of players is reached:
if(PhotonNetwork.playerList.Count() == PhotonNetwork.room.MaxPlayers)
{
        if (PhotonNetwork.player.IsMasterClient == false)
        return;
	PhotonNetwork.room.IsOpen = false;
        PhotonNetwork.room.IsVisible = false;
}
2. Player in lobby press the refresh button, clear all the rooms UI and repopulate it:
public void OnRoomListRefresh()
{
	// Clear the List
	clearRoomsList ();

	// Populate Room List
	populateRoomsList();	
}

void clearRoomsList()
{
	foreach (Transform child in g_oRoomsListPanel.transform)
	{
		Destroy(child.gameObject);
	}
}

// Populate the available rooms list
void populateRoomsList()
{
	foreach (RoomInfo roomInfo in PhotonNetwork.GetRoomList ())
	{
		if(roomInfo.IsVisible == true)
		{
			addRoomInfo(roomInfo);
		}
	}
}
The problem is that the room, which has been set not visible by the masterclient is still added inside the UI rooms list.
Furthermore, when I print the roominfo.playercount of that particular room, it shows me one player less.
(Eg. inside the room there are 2 players, however inside lobby it tells me there is only 1)

Any idea of what it could be the issue here?
Inside the game room.IsVisible is definitely false as I am printing it on the console.

Kind regards,
Pier

Bug in PunBasics-Tutorial on Jump

$
0
0
I just read out PUN Basics Tutorial. I did all step by step but in the end robo still damage himself on jump. I opened included Demo in PUN asset but this bug still there. Probably main bug somwhere in PlayerManager with photonView.isMine in OnTriggerEnter/Stay. How to fix it?

Photon conflicts with Json.Net for Unity

$
0
0
In my current project I have imported the Photon Unity Networking package and the Json.Net for Unity package from parentElement.

This causes the error: Assets/3rdPartyTools/Photon Unity Networking/Editor/PhotonNetwork/AccountService.cs(181,45): error CS0433: The imported type `Newtonsoft.Json.JsonConvert' is defined multiple times.

Removing the Newtonsoft.Json.dll from the Photon Unity Networking\Editor\PhotonNetwork folder fixes the build errors, but now I am getting:

A script behaviour has a different serialization layout when loading (Read 24 bytes but expected 64 bytes)
and
PhotonNetwork threw an exception. Type: System.TypeInitializationException

Json.Net for Unity doesn't use the Newtonsoft.Json.dll, so I can't just remove it to clear the conflict.

Has anyone else ever experienced this problem? How did you resolve it?

Facing Problems in getting roomlist in unity photon networking

$
0
0
Hello Guys!

I am facing problem of getting rooms list. I have tried everything I read all the other questions related to topic but none of them helped me out. How can I get rooms created in game. Here is the that I have written. Any help would be appreciated.

public GameObject RoomBoardEntry;
 public GameObject RoomBoardPanelParent;

 // Update is called once per frame
 void Update () {
         foreach (RoomInfo room in PhotonNetwork.GetRoomList()) {
             Debug.Log (room.Name+ " Name ");
             GameObject RoomObject = (GameObject)Instantiate (RoomBoardEntry);
             RoomObject.transform.SetParent (RoomBoardPanelParent.transform);
             RoomObject.transform.Find ("NameHeader").GetComponent<Text> ().text = room.name;
         }
     }

Help me with photon lags i can t find probleme

$
0
0
Hello
Iam working with Unity 2017 Personal and trying android jumping platformer game
but i dont know why my game lagging (Players positions,and Jumping animations too...)

Here is lagging proof:


Okey is possible to downgrade the lags? or what iam doing wrong?

Here is my photon view component



This is my Sync Script:

using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class Sync : Photon.PunBehaviour {



private Animator m_Anim;
private bool isRunning;
private float Speed;


private Vector3 realPosition;
private Quaternion correctPlayerRot;

// Update is called once per frame
void Update()
{
if (!photonView.isMine)
{
transform.position = Vector3.Lerp(transform.position, realPosition, Time.deltaTime * 5);
transform.rotation = Quaternion.Lerp(transform.rotation, this.correctPlayerRot, Time.deltaTime * 5);
m_Anim.SetBool("Ground",isRunning);
m_Anim.SetFloat("Speed",Speed);
}
}

void OnPhotonSerializeView(PhotonStream stream, PhotonMessageInfo info)
{
if (stream.isWriting)
{
// We own this player: send the others our data
stream.SendNext(transform.position);
stream.SendNext(transform.rotation);
stream.SendNext(m_Anim.GetBool("Ground"));
stream.SendNext(m_Anim.GetFloat("Speed"));

}
else
{
// Network player, receive data
this.realPosition = (Vector3)stream.ReceiveNext();
this.correctPlayerRot = (Quaternion)stream.ReceiveNext();
isRunning = (bool)stream.ReceiveNext();
Speed = (float)stream.ReceiveNext();
}
}



// Use this for initialization
void Start(){
m_Anim = GetComponent();
}


}



Thanks for any help




How to serialize view if you are not an owner of an object?

$
0
0
Card game, 2 players. I create cards on the master client side, and the owner of these cards is the master client. if I'm a master client and I move the cards, then on the second client the cards are also moved (I use OnPhotonSerializeView), it's good. But if you move these cards on the client side, nothing happens on the master client, because the owner of these cards is master client. How to serialize view if you are not an owner of an object?
Thank you in advance

Synchronizing a missile (projectile)!

$
0
0
Hello everyone, I'm having trouble synchronizing a bullet in my game! It behaves like a missile, and I need to make sure the projectile is in the same position on all machines!

Doing a position compensation, I can not guarantee that! I know I'm doing something wrong, because we see this guarantee in some games, like the Pharah missile in Overwatch, or the rocket launchers in Quake Arena, etc...

private void FixedUpdate() {
    if (PhotonNetwork.isMasterClient)
     {
          myRigidbody.MovePosition(myTransform.position + myTransform.forward * Time.deltaTime * speed);
     }
     else
     {
          lerpFraction = lerpFraction + Time.deltaTime * 9;
          myRigidbody.position = Vector3.Lerp(currentPosition, networkPos, lerpFraction);
     }
}

[Feature request] PUN RPC message aggregation

$
0
0
Since OnPhotonSerializeView messages are already batched together, the framework must already exist.
Can you please add this feature to RPC calls as well? Specifically, multiple RPC calls sent in the same frame to the same target should be able to batch. This would reduce Msg/s counts drastically, at least for us, but I'm sure others would benefit from it as well.

Cannot send messages when not connected. Either connect to Photon OR use offline mode! Photon

$
0
0
Hello,

my game works fine. Players can play all features smoothly but suddenly game freezes and few players get this message: "Cannot send messages when not connected. Either connect to Photon OR use offline mode! Photon"

I don't understand why players are suddenly disconnecting.

Can anyone help ?

Thanks!

Simplest workflow for moving users between rooms/scenes

$
0
0
Hi,
Is there a diagram (or even a simple example project) that illustrates the basic code/steps required to do something like this:

- 2 scenes (for basic concept - but would extend it for many more scenes)
- Players join scene 1 / room 1 and can see each other.
- teleport pad in the room. As each player touches it they go to scene 2 / room 2. Only players in the same room/scene can see each other.
- same in room 2 - touch a teleport pad and you go back to scene 1 / room 1.

I just want to make sure I write the correct code to detect a "player" correctly, create/destroy players/connections to keep everything stable. What are the best practices?

Thanks!

WebRPCs and AuthCookie

$
0
0
Hello!
I got Custom Authentication and WebRPCs working for my Photon Project..
I have a Script on my PHP Server that requires the User to be logged in.. and I need to get data from it.
How do I get the AuthCookie and send it with the WebRPC so the Script knows that the User is logged in?

I use Sessions on my PHP Server
if(!isset($_SESSION['user']))
{
//user logged in.. send data
}
else
//error

Thanks!
Regards

What can cause an ExceptionOnReceive disconnect?

$
0
0
After updating PUN to the latest version, it can't connect anymore on some networks (but works fine on others).

We're using a Photon Server with a custom plugin hosted on Amazon.

What are some possible causes for getting an ExceptionOnReceive disconnect?

Players doesn't find or create room .

$
0
0
player from different regions or ip's didnt find or create room .
even when i log it like foreach(rooms in photonRoomlist).
it return count 0.

Is there a way to store a large piece of binary data in the Turnbased room?

$
0
0
Hi.

I'm trying to store a texture in the Turnbased room, to make it persistent. The texture size is quite large and when I try to get a byte array from it and save it to room Custom Properties - there's a lag and Photon disconnects me.

Is there a convenient way to do that?
Or should I save it using direct call to my Azure Website (the one behind Photon Web-hooks).
Thanks

Partial Network Culling

$
0
0
Hi everyone,

I would like to optimise the number of messages per second in one room.

My game takes place in a FPS with large scale maps.
I can't use the method that is presented in the example (using a cells grid corresponding to groups each player subscribes to) because I want each client to send messages to all the others, but with different frequencies depending on the distance.

I found this article: https://www.m2h.nl/network-traffic-culling/ describing a method to do so, but it's a bit unclear on how it works with PUN and the code is not available anymore.

What is the best way to make dynamic message per second fram rate between players in function of their distance(or something else)?

Thank you,

Photon cloud and mySql...

$
0
0
Hi all! I use photon cloud in my unity project and i too use mySql db... How me true save player setting in db? I create rpg with big scene... Thank you all!

IPunPrefabPool Example for Object Pool

$
0
0
Hi ,

I want to pool my effects in my network game.

Can you pleas provide some example how to do it .

What i tried
1. Add PhotonView in Effect and Call PhotonNetwork.Instantiate

And it gets visible in all screens.

How to pool this ?

What i want to do is throw grenade and show effect.


Regards
Unity Learner



PUN Drag & Drop Pickup Inventory

$
0
0
First off, I'm very new to Photon and MP coding in general, so I'm making this up as I go along.

I'm hoping someone can give me some general advice on approach/design pattern.

I have a scene in which I spawn players. Within the scene there are item managers that spawn items on start up using InstantiateSceneObject. All the players can see the items. All good.

I use Easy Touch asset to making hooking up interaction events nice and simple. Example of an item in the screenshot.

The problem is, the click, drag, etc events only fire right now for the master client, though there is ONE item in the scene that other players can also interact with (for some unknown reason), but let's just ignore that for a sec.

I've seen a lot of examples (some included with PUN) of pickups that the player just runs into, firing an OnCollision, which then easily passes the player and their PhotonView, etc. In my case though, players will drag and drop the items they see into their inventory. Here's a video of how it works for the master client - http://www.stevejarman.com/temp/photon1.mp4

Anyway, I'm rambling a bit, but I'm basically trying to get some hints on how to approach those OnSimpleTap, OnDragStart, OnDragEnd implementations, to make them "MP aware".


Viewing all 8947 articles
Browse latest View live


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