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

Is this disconnections graph healthy?


[HELP] PhotonMessageInfo.photonView null when using OnPhotonInstantiate

$
0
0
I have no idea what's going on.

I have a prefab with a photon view on it and a script that uses OnPhotonInstantiate.

The method is being called, however the photonView stored within the info parameter is null!

Should this not return the photonView on the prefab?

I greatly appreciate any responses! I'm desperate for answers...

Synchronize Objects without an Owner (Not using OnPhotonSerializeView)

$
0
0
Hello guys!

I am trying to synchronize positions and rotations of objects in my game. I have tried OnPhotonSerializeView and PhotonTransformView but I realised that those only work when you one of the clients take ownership of the object. The owner will be responsible for sending out the updates to other clients.

What I need:
Multiple players updating an object that will be reflected in other clients. Any player can take control of the object and other clients have to update the object's position according to the owner.

Thanks!
Justin

Spawn enemies AI

$
0
0
Hi everyone I'm beginner in Unity and Photon, so I've a problem with the enemies AI spawning.
I create a NetworkManager with Photon.Monobehaviour and a method SpawnEnemy() when the number of enemies is lesser then MAX_NUMBER_ENEMIES, but I received this error "Failed to Instantiate prefab: Prefabs/Enemy. Client should be in a room." and I don't understand what it is.

NEED HELP WITH WEAPON SWITCH SYNC

$
0
0
hi, i am still new to photon networking, and i am having trouble with weapon switch. i want the weapon switch to update to the other clients.

here's my code for weapon switch. i dont know where to start XD

public int selectWeapon = 0;

void Start()
{

SelectWeapon();

}



void Update()
{
SelectWeapon();
if (Input.GetAxis("Mouse ScrollWheel") > 0f)
{
if (selectWeapon >= transform.childCount - 1)

selectWeapon = 0;

else

selectWeapon++;
}

if (Input.GetAxis("Mouse ScrollWheel") < 0f)
{
if (selectWeapon <= 0)

selectWeapon = transform.childCount - 1;

else

selectWeapon--;
}

if (Input.GetKeyDown(KeyCode.Alpha1))
{
selectWeapon = 0;

}

if (Input.GetKeyDown(KeyCode.Alpha2))
{
selectWeapon = 1;

}
if (Input.GetKeyDown(KeyCode.Alpha3))
{
selectWeapon = 2;

}


}



public void SelectWeapon()
{
int i = 0;
foreach (Transform weapon in transform)
{
if (i == selectWeapon)
weapon.gameObject.SetActive(true);
else

weapon.gameObject.SetActive(false);

i++;
}

}

Spawn on the network a gameobject already in the scene

$
0
0
Hi,
I am able to load from Resources folder a prefab and instantiate it on the scene + on the network.
Now I want to instantiate over the network a gameobject that already exist in the scene (so without loading it from Resources folder). Is this possible?

Why Pun demo dont use Service funcion

$
0
0
hi all, We Alwalys Use Service function to connect the Host.
like this:
void Update()
{
if(peer!=null)
peer.Service();
}

But Where is the "service" function in Pun demo.
THANK YOU!

Illegal view ID with DontDestroyOnLoad

$
0
0
The code works like this:

1) Menu scene is loaded and there is a script Level.cs.
2) In its awake, if a "Master" object does not exist then it is instantiated (not Photon.Instantiate()).

Master object contains all kinds of objects such as the network manager and more items with Photon views.

3) If a map is selected and loaded, the master object is persisted since it has the DontDestroyOnLoad.

However, sending any RPC's, using photonviews from previous scene (the menu scene, photonviews under master objects) results in an error "Illegal view ID:0 method: *methodname* *gameobject name*

How to solve this?

PhotonView has no method "X" marked with [PunRPC] - Accessing a RPC method from a base class?

$
0
0
I'm getting the error "PhotonView with ID 1 has no method "PunTakeDamage" marked with the [PunRPC](C#) ..." when calling it.

My player class is calling a public method "lf.TakeDamage(primaryDamage);" when hitting an enemy with a raycast. I get the component Lifeform from my enemy with is a base class from the enemies more specific class. The class structure looks like this:

> Lifeform
> SkeletonBaddy : Lifeform
> SpecificEnemy : SkeletonBaddy

"TakeDamage()" looks like this:

public void TakeDamage(int n)
{
photonView.RPC("PunTakeDamage", PhotonTargets.All, n);
}

It is at the .RPC line that I get the error. In the same Lifeform class I have the method marked as a [PunRPC]:

[PunRPC]
private void PunTakeDamage(int n)
{
healthCurrent -= n;
if (healthCurrent <= 0) Die();
}

I'm wondering if the reason why I'm getting this error is due to the PunRPC being nested within 2 base classes since technically when I find the Lifeform script from my hit enemy it is actually finding the class that inherits a class that inherits Lifeform. This seems odd to me but I don't really understand the inside of Photon to make a quality guss.

Any help is appreciated.

better way to synchronise game pickup items, joining player getting rpcs for dead views

$
0
0
I've noticed an issue with my game, and am wondering how to redesign to get around it. With certain loot objects, i'm using rpcs successfully, masterclient authoritative. The objects are either destroyed or instantiated base on these RPCs.

The objects in question are storage lockers - fixed gameobject in game that contain other items, that are swapped in and out - players can add items into the box from their own inventory [rpc to master to create item in box] and take items out to keep [rpc to master to destroy item in box].
anytime a player interacts with the locker, rpc is sent to master to gather latest contents list.
[Obviously there are other rpcs sent to update the players inventory with this activity, but these are not the problem as far as i can tell].

However a player joining the game later, is getting buffered RPCs for the objects that no longer exist [as they were already picked up/destroyed].
The game isn't crashing, I'm just getting warnings in the console, but I have realised I need to handle this in a better way.

I have a few ideas already but I'm not sure they're good ideas:
1. dont buffer these rpcs only send to master - push to new player when they query the list [if they come within trigger range of the object for example] - problem with that is that when a player takes an item out of the box the other players will need to be notified they have this object in their possession now.

3. dont destroy the item, maybe turn off its renderers instead, although that will still result in rpc being sent to new player when something happens to that object
4. have looked into custom room properties and that looks very promising but am not sure that adding in hundreds of pickup items to custom room properties is a good way to go about things or if it's possible
5. back to not putting photonviews on the items at all and syncing whether they exist or do not another way.

I'm still looking into this but was hoping someone has some ideas, thanks!

Photon Bolt vs. PUN

$
0
0
I briefly looked into Bolt and PUN. In terms of technology, looks like Bolt is more superior since it is peer to peer. But PUN looks like more widely used. How can the user choose between those two? what is the pros and cons? I am currently building a RPG Game, the worlds and game content will be constantly added in. Can anyone help me decide which technology i should use?

PUN Update Briked my game: Assets/Photon Unity Networking/Plugins/PhotonNetwork/PhotonNetwork.cs(320

$
0
0
Ok so after Updating photon I get ALOT of error in the Demo's folder and after Deleting the Demos folder
I get X2 Assets/Photon Unity Networking/Plugins/PhotonNetwork/PhotonNetwork.cs(3202,22): error CS0117: `SceneManager' does not contain a definition for `LoadScene'

(THIS IS A FRESH PROJECT WITH NOTHING BUT THE NEW PUN Package from the Assets store.)

Cross-Platform Assymetric Multiplayer with PUN

$
0
0
Hello everybody,

currently i'm working on a project for my virtual reality class at my university. I just tried out the Photon Voice Demo Scenes since the design for my application needs a voice chat between a VR user on PC and a Mobile User on Android/iOS. Everything went fine so i chose PUN as my networking solution for now.

The project will feature different tasks, mechanics, input solutions etc. but the players share the same "room". Any thoughts and recommondations what i should read and tutorials i should try? What would your approach be?

how can i set RomeOptions to JoinRandomRoom() ?

$
0
0
hello, basically i want to rejoin to a specific room if in case one of my player gets disconnected.
So, for that i have to set TTL RoomOption. it cant be set with CreateRoom(). But, if i want to use JoinRandomRoom(), then how do i set this?
Bottomline is, Can rejoining be achieved in JoinRandomRoom() ?

Client hosted servers

$
0
0
So, we're developing a multiplayer fps and we were wondering if there's any official support for client hosted games, so we can have official games, hosted by us and community servers, hosted by player, is there any way to do that with photon?

Question About PUN and Self Hosting

$
0
0
Hi, I'm new and wanting to learn about Photon. Currently I'm going to be working on an online RPG (An MMO, just small scale. Like 10-20 players max, but will have skills, classes, a bank, chat, guilds, etc.) My goal with this project is to learn about networking with Photon. I am wondering, is there a way to host the game servers and create it just using C# and Photon in a console application, or do I have to make the game servers with Unity? I am wanting to have the client using Unity, and the servers be using just Photon, completely decoupled from Unity. I looked at the SDK's, and only found PUN, Unity3d On Premise(On Premise, since I'm going to self host all my servers in the rack I have at a datacenter), and Photon server SDK. Like I said, I'm wanting to use Unity as a client, and Photon as the game server completely decoupled from Unity. Just not sure if it's possible. Worst case, I will have to make the server a seperate Unity project. Thank you all for your time.

Failed to network remove gameobject

$
0
0
Hi I have looked all over and haven't been able to figure this out. I am instantiating objects with PhotonNetwork.InstatiateSceneObject. The object the script is attached to has a photon view and is owned by the scene. In the script I check if (photonview.isSceneView). My game is a drop in and out kind of game. When I start the game in the editor, and then on my phone, everything runs fine. If I then exit playing on my computer and come back in, I get errors saying "Failed to instantiate Gameobject. Client is neither the owner or Master Client". I thought I read when the master client leaves, it gets transferred automatically to a new player. So I don't know why it would be trying to instantiate from the newest player that joined when I specifically have if(isSceneView). Any help would be appreciated. Thanks! :smile:

PUN+ WebGL errors connecting to localhost

$
0
0
I'm running into the following errors connecting to a Photon Plugin Server on localhost when connecting with a WebGL PUN client. Specifically I see the following errors in the Chrome browser log:
WebSocket connection to 'wss://127.0.0.1:9090/' failed: Error in connection establishment: net::ERR_INSECURE_RESPONSE
and
Exiting receive thread. Server: wss://127.0.0.1:9090:0 Error: Abnormal disconnection.

However, I am able to use the PUN client in the Unity Editor to connect without any errors, other platforms connect fine using UDP. It seems to specifically be the built client that has issues connecting.

Setup:
  • Unity 5.6.0f3
  • WebGL with code stripping turned off (tried on and off)
  • Photon-OnPremise-Server-Plugin-SDK_v4-0-29-11263 with a custom plugin
I've seen this post, but I'm barely sending any data at all and it still doesn't connect at all when running from the actual WebGL build output by Unity.

I also followed the instructions here to allow running from chrome with local file access. Microsoft Edge cannot connect either.

In order to even get the unity editor to connect I had to solve the certificate and secure websocket configuration as shown here.

So... the question is, why does the webgl client in the editor behave differently than the webgl client that actually gets built?

Anyone run into this? I must be missing something simple somewhere.
Thanks for any help!
C

waiting room countdown trouble

$
0
0
Hello all, I'm having a little trouble on sending countdown timer with RPC.
I have a waiting room which all connected (to the room) players gather in list. So when Player 1 creates room and waits other players to join. Until 60 sec countsdown. Debug.Log works but timer starts to down on each player individually
using UnityEngine;
using System.Collections;
using UnityEngine.UI;

public class TestLobby : MonoBehaviour {

	public PhotonView pv;
	public float timer = 60f;
	public Text t;


	void Start ()
	{
		
	}

	void Update ()
	{
		if (PhotonNetwork.inRoom) {
			if (PhotonNetwork.isMasterClient) 
			{
				pv.RPC ("ShowTimer", PhotonTargets.All);
				Debug.Log ("Chek for sending an RPC");
			}
		} 
		else 
		{
			timer = 60f;
		}
	}
		

	[PunRPC]
	public void ShowTimer ()
	{
		timer -= Time.deltaTime;
		t.text = "Game Begins In: " + timer.ToString ("f0");
		Debug.Log ("Check for receiving an RPC");
	}
}

Recommendations about Max Players

$
0
0
Hello,

Im actually working on a mmofps, both server and cloud... I would like to know what are your recommendations about the max numbers of players in room?

Default value is 4. But I only use PUN for player movement and animation synchronisation. My server works for the rest.

So how many players can be united in same place (room) at same time.

Thanks you
Viewing all 8947 articles
Browse latest View live


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