#archived-networking

1 messages ยท Page 105 of 1

inland sand
#

But I won't give up

jovial pike
inland sand
jovial pike
#

ouh...

#

for both players?

inland sand
#

for the ball

jovial pike
#

ok

inland sand
#

And yes both player @jovial pike

jovial pike
#

do i have to change something in the script?

inland sand
#

no ig

jovial pike
#

thx

inland sand
#

You can follow along this tutorial

jovial pike
#

๐Ÿ˜„

#

thank you

jovial pike
# inland sand https://youtu.be/93SkbMpWCGo
if (!this.photonView.IsMine)
            {
                if (m_UseLocal)

                {
                    tr.localPosition = Vector3.MoveTowards(tr.localPosition, this.m_NetworkPosition, this.m_Distance * (1.0f / PhotonNetwork.SerializationRate));
                    tr.localRotation = Quaternion.RotateTowards(tr.localRotation, this.m_NetworkRotation, this.m_Angle * (1.0f / PhotonNetwork.SerializationRate));
                }
                else
                {
                    tr.position = Vector3.MoveTowards(tr.position, this.m_NetworkPosition, this.m_Distance * (1.0f / PhotonNetwork.SerializationRate));
                    tr.rotation = Quaternion.RotateTowards(tr.rotation, this.m_NetworkRotation, this.m_Angle * (1.0f / PhotonNetwork.SerializationRate));
                }
            }
#

i never opened this script

#

why is there an error?

jovial pike
#

I will try it

#
if (pv.IsMine && ptv.photonView.IsMine)
#

can i use this?

#
        ptv = GetComponent<PhotonTransformView>();
#

ptv is my photontransformview

#

no it doesnt work

inland sand
jovial pike
#

ok

inland sand
#

You gotta add a photon view component

jovial pike
#

i have

inland sand
#

A photon transform view component

#

And animator view if you have any animator

#

Animation*

jovial pike
#
 void FixedUpdate()
    {
        if (pv.IsMine)
        {
            float horizontal = Input.GetAxis("Horizontal2");
            if (Input.GetKey(KeyCode.I))
            {
                RaycastHit2D hit = Physics2D.Raycast(gameObject.transform.position, Vector2.down, rayCheckDistance);
                if (hit.collider != null)
                {
                    rb.AddForce(Vector2.up * jump, ForceMode2D.Impulse);
                }
            }
            rb.velocity = new Vector3(horizontal * speed, rb.velocity.y, 0);

            Flip(horizontal);

            if (Input.GetKey(KeyCode.K))
            {
                gravityScale = 5;
            }
            else
            {
                gravityScale = 1;

            }
            rb.gravityScale = gravityScale;
        }
    }
#
 Rigidbody2D rb;
    PhotonView pv;
    PhotonTransformView ptv;

    void Start()
    {
        rb = GetComponent<Rigidbody2D>();
        pv = GetComponent<PhotonView>();
        ptv = GetComponent<PhotonTransformView>();
    }
inland sand
#

If using rigidbody, use photon rigidbody view

jovial pike
#

i have on in my prefab

#

but do i have to call it in the script?

inland sand
#

No

jovial pike
#

ok

inland sand
#

You only need photon view

jovial pike
#

ouh ok

#

then i have all

#

i think

inland sand
#

Then what's the error?

jovial pike
#

i really dont know

#

i can show my components

inland sand
#

then it should be working right?

jovial pike
#

i have the script and the components

inland sand
#

Build and test it out

jovial pike
#

ok

inland sand
#

Or wait

#

Nvm

jovial pike
#

now it doesnt even start

inland sand
#

Eh

#

Why?

jovial pike
#

because of this

inland sand
#

Are you following along with the tutorial? @jovial pike

jovial pike
#

yes

#

it worked but i dont know what i changed

jovial pike
inland sand
#

ya why are you using photonviewtransform.ismine

#

You just need photonview.ismine

jovial pike
#

i tried it

#

ok

jovial pike
inland sand
#

it's still having that error?

jovial pike
#

yes

#

again

inland sand
#

Umm, remove photon transform view

#

And andd transform view classic

jovial pike
#

ok

jovial pike
#

ouhh

#

i know why

#

i also put one on the ball

inland sand
#

ig you should re do everything and follow along with the tutorial because there are many things i.e wrong In your code

jovial pike
#

but can i use isMine on the ball?

inland sand
#

you want the ball to be controlled by player?

jovial pike
#

nope

#

just a rigidbody

inland sand
#

ismine is used when you don't want your player to move others' player

jovial pike
#

ok

#

then i remove the transform on the ball

inland sand
#

its stated in the tutorial

inland sand
jovial pike
#

but you cant controll the ball

inland sand
#

Transform view syncs the transform to all the clients on server

jovial pike
#

ouhhh

#

ok

inland sand
#

bruh, watch the tutorial I sent you abovr

jovial pike
#

do the camera need a photon transform?

#

ok

inland sand
jovial pike
#

ok

#

thx

#

it still doesnt work ๐Ÿ˜ฆ

jovial pike
#
if (pv.IsMine)
        {
            float horizontal = Input.GetAxis("Horizontal");

            if (Input.GetKey(KeyCode.W))
            {
                RaycastHit2D hit = Physics2D.Raycast(gameObject.transform.position, Vector2.down, rayCheckDistance);
                if (hit.collider != null)
                {
                    rb.AddForce(Vector2.up * jump, ForceMode2D.Impulse);
                }
            }
#

Is anything missing?

inland sand
jovial pike
#

yes

cedar cloak
#

Photon PUN: I need to sync the player that is just entered in the room, so inside the OnPlayerEnteredRoom how can I call an RPC specifically aimed to that new player?

jovial pike
inland sand
#

Not with scene

jovial pike
#

ouh

#

in the ConnectToServer Script?

#

OrCreateRoom Script?

#
public override void OnJoinedRoom()
    {
        PhotonNetwork.LoadLevel("SampleScene");
        PhotonNetwork.Instantiate("Player", spawnLocationLeft.transform.position, Quaternion.identity, 0);
    }
#

like this?

spring cargo
#

Hello Everyone,
I was thinking if it's possible to control a standalone application using my mobile phone (offline - no internet)

#

Like I create a scene in Unity with a cube, make it a standalone app and then maybe change the color of that cube using my phone. My phone can have the same application. Just that everything should be offline. I want a way to communicate with the standalone application using my phone.

icy thorn
#

Are you ok with going via LAN? Bluetooth?

#

Are the cube app and phone on the same LAN?

#

Are they in different places geographically?

#

LAN networking doesnt require internet

#

But going to different houses or to a different coubtry does

#

It will require going over the internet, and there isnt much yiu can do about that

spring cargo
#

@icy thorn yes bluetooth/lan works. It would be in the same space. Just like how we have a controller for a PS4 system.

#

Could you help me with this?

jovial pike
#

can you help me with my photon problem?

#

I do not know what I'm doing wrong

river meteor
#

whats the problem

jovial pike
#

it doesnt sync

river meteor
#

show me your code for room creating/joining you can herte on dm

jovial pike
#
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
using Photon.Pun;

public class CreateAndJoinRooms : MonoBehaviourPunCallbacks
{
    public InputField createInput;
    public InputField joinInput;

    public void CreateRoom()
    {
        PhotonNetwork.CreateRoom(createInput.text);
    }

    public void JoinRoom()
    {
        PhotonNetwork.CreateRoom(joinInput.text);
    }

    public override void OnJoinedRoom()
    {
        PhotonNetwork.LoadLevel("SampleScene");
    }
}
jovial pike
#

i switched the join and create button

#

now it loads longer

#

but the second screen isnt loading at all

jovial pike
river meteor
#

why are you ccreating room in join room?

#

You should use PhotonNetwork.JoinRoom(joinInput.text)

jovial pike
#

I thought I changed it

#

sorry

river meteor
#

you also should have before it all ConnectToMaster function

#

sorryu

#

connectusingsettings

jovial pike
#
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using Photon.Pun;
using UnityEngine.SceneManagement;

public class ConnectToServer : MonoBehaviourPunCallbacks
{
    void Start()
    {
        PhotonNetwork.ConnectUsingSettings();
    }

    public override void OnConnectedToMaster()
    {
        PhotonNetwork.JoinLobby();
    }

    public override void OnJoinedLobby()
    {
        SceneManager.LoadScene("Lobby");
    }
}
#

This Script is in my Loading Scene

river meteor
#

ah you are using lobby system, so I dont know how it is going

jovial pike
#

i really dont need a lobby

#

I thought it wouldnt work without a lobby

#

omg it works

#

its laggy but it works

river meteor
#

so what was issue?

jovial pike
#

but i really thought i have changed it

jovial pike
river meteor
#

yeah sure

jovial pike
#

it always spawns both player

#

i know why but i dont know how to fix it

river meteor
#

I think because you have already player placed in scene

jovial pike
#
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using Photon.Pun;

public class LeftSpawnPoint : MonoBehaviour
{
    public GameObject spawnLocationLeft;

    void Awake()
    {
        spawnLocationLeft = GameObject.FindGameObjectWithTag("SpawnPointLeft");
    }

    void Start()
    {

        SpawnPlayer();
    } 

    private void SpawnPlayer()
    {
        PhotonNetwork.Instantiate("Player", spawnLocationLeft.transform.position, Quaternion.identity, 0);
    }
}
jovial pike
#
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using Photon.Pun;

public class RightSpawnPoint : MonoBehaviour
{
    public GameObject spawnLocationRight;

    void Awake()
    {
        spawnLocationRight = GameObject.FindGameObjectWithTag("SpawnPointRight");
    }

    void Start()
    {

        SpawnPlayer();
    } 

    private void SpawnPlayer()
    {
        PhotonNetwork.Instantiate("Player2", spawnLocationRight.transform.position, Quaternion.identity, 0);
    }
}
river meteor
#

move you instantiate function to OnJoinRoom callback and it shouldbe ok

jovial pike
#

this i for the right spawner

river meteor
#

and why you have two different prefabs for players?

jovial pike
#

because they have different movement scripts

#

i controll one with "w a s d" and the other with "i j k l"

river meteor
#

aaah okey okey

#

but I can give you some advice about that

jovial pike
#

really?

river meteor
#

you can also have only one prefab but two different movement scripts and apply for the same player but at start disable one.. then you can enable them determining if one of them is master client

#

depending on in if one of them is master client

#

I consider your game will always have max two players, right?

jovial pike
#

yes

river meteor
#

I will do this in way I described but I dont say your solution is bad or something

#

treat it just like a tip ๐Ÿ˜„

jovial pike
#
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
using Photon.Pun;

public class CreateAndJoinRooms : MonoBehaviourPunCallbacks
{
    public InputField createInput;
    public InputField joinInput;

    public GameObject spawnLocationLeft;
    public GameObject spawnLocationRight;

    public void Awake()
    {
        spawnLocationLeft = GameObject.FindGameObjectWithTag("SpawnPointLeft");
        spawnLocationRight = GameObject.FindGameObjectWithTag("SpawnPointRight");
    }
    public void CreateRoom()
    {
        PhotonNetwork.CreateRoom(createInput.text);
    }

    public void JoinRoom()
    {
        PhotonNetwork.JoinRoom(joinInput.text);
    }

    public override void OnJoinedRoom()
    {
        PhotonNetwork.LoadLevel("SampleScene");
        PhotonNetwork.Instantiate("Player", spawnLocationLeft.transform.position, Quaternion.identity, 0);
        PhotonNetwork.Instantiate("Player2", spawnLocationRight.transform.position, Quaternion.identity, 0);

    }
}
#

ouh wait

river meteor
#

yep but with this code it always will instantiate two players

#

no matter if second one has joined

jovial pike
#

and the other problem is that he cant find the spawnLocations

#

because its not the right scene

river meteor
#

and when second player will join the another two players will spawn

jovial pike
#

ouh

#

then i have to use your ideo

#

*idea

#

so i give my prefab player both scripts an when he spawns i will disable one of the scripts

river meteor
#

slove first of all problem with player spawning - give them temporary fixed locations in code

#

then workaround the spawnpoint system

jovial pike
#

ok thx ๐Ÿ˜„

river meteor
#

solution for you problem is just to move your code

#
        spawnLocationLeft = GameObject.FindGameObjectWithTag("SpawnPointLeft");
        spawnLocationRight = GameObject.FindGameObjectWithTag("SpawnPointRight");```
#

this into another place ๐Ÿ˜‰

jovial pike
#

i removed that

#

i will use Vector3 (0,0,0)

river meteor
#

no, you can leave it

#

but think about where you can put it

jovial pike
#

ok

river meteor
#

you already say what is the solution for it

river meteor
jovial pike
#

ouh so i can use the spawnpoints

#

nice

#

ok i know what to do

#

thx

river meteor
#

remember, code is executed from top to the bottom

#

so

#
  1. Load a scene
  2. Load spawnpoints
  3. Spawn the players
#

viola

jovial pike
#

i will set a bool variable on my spawn script. and i will set it in my CreateAndJoinRoom script to true.

#

can i do that

river meteor
#

you dosent have to

jovial pike
#

ouh ok

river meteor
#

look into your OnJoinRoom callback

#

OnJoinedRoom *

jovial pike
#

but the CreateAndJoinRoom is on another scene

#

is that a problem?

river meteor
#

nope

jovial pike
#

ouh nice

#

now i get it

river meteor
#

if you have DontDestroyOnLoad

#

it is not

jovial pike
#

after LoadLevel i can instantiate the spawnpoint and player

river meteor
#

in playable scene you can place fixed spawnpoints

#

after loading scene in OnJoinedRoom

#

You can get these spawnpoints with your code from Awake function

#

then

#

Instantiate players

#

you still didnt get it? ๐Ÿ˜„

jovial pike
#

i got it

#

a bit

river meteor
#

I know the easiest solutions are the hardest one to find

#

xD

jovial pike
#

xD

#

yes

river meteor
#

and I think it is the moment when you should stop coding, get a walk, comeback and work it around

#

๐Ÿ˜„

#

I do it everytime when my mind is blowing, but instead of getting a walk I am going to my proper job

jovial pike
#

when i'm sitting on something i work on it until it works

#

I've been trying to get my photon working all day

#

but i will make it

#

and thanks for you help

jovial pike
river meteor
#

no!

#

keep them in the correct playable scene

jovial pike
#

i have

#

i will try something

#

but my problem is i dont know how i can find the GameObject in my CreateRoom Script

#

i cant use this

river meteor
#

okey I will tell you what is the solution

#

yes you can

jovial pike
#

how

#
spawnLocationLeft = GameObject.FindGameObjectWithTag("SpawnPointLeft");
        spawnLocationRight = GameObject.FindGameObjectWithTag("SpawnPointRight");
jovial pike
river meteor
#
    public override void OnJoinedRoom()
    {
        PhotonNetwork.LoadLevel("SampleScene"); // FIRST SWITCH SCENE
        spawnLocationLeft = GameObject.FindGameObjectWithTag("SpawnPointLeft"); // NOW WHEN WE ARE ON CORRECT SCENE WE CAN GET THE SPAWN POINTS
        spawnLocationRight = GameObject.FindGameObjectWithTag("SpawnPointRight");
        PhotonNetwork.Instantiate("Player", spawnLocationLeft.transform.position, Quaternion.identity, 0); // SPAWNPOINTS ARE NO MORE NULL REFERENCE SO WE CAN USE THEM
        PhotonNetwork.Instantiate("Player2", spawnLocationRight.transform.position, Quaternion.identity, 0);

    }```
jovial pike
#

you can do that???

#

wow

river meteor
#

I think so

#

but your script CreatAndJoinRooms must be DontDestroyOnLoad

jovial pike
#

ok

#
        DontDestroyOnLoad(gameObject);
#

in awake

river meteor
#

but this gameobject must be with createandjoinrooms

#

script

jovial pike
#

yes

#

he cant find the player

#
        PhotonNetwork.Instantiate("Player", spawnLocationLeft.transform.position, Quaternion.identity, 0);
#

this is the line 38

jovial pike
river meteor
#

hmm

#

okey so maybe this solution is not a right one xD

jovial pike
#

xD bruh

river meteor
#

okey just put positions in code

jovial pike
#

oki

river meteor
#

I will take a look later how I have it solved with spawnpoints

jovial pike
#

kk

#

thx

ornate zinc
jovial pike
#

thx but i found a solution

ornate zinc
jovial pike
jovial pike
jovial pike
# jovial pike can you help me with another problem?
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
using Photon.Pun;

public class CreateAndJoinRooms : MonoBehaviourPunCallbacks
{
    public InputField createInput;
    public InputField joinInput;

    private GameObject Player;

    public void Awake()
    {
        DontDestroyOnLoad(gameObject);
    }
    public void CreateRoom()
    {
        PhotonNetwork.CreateRoom(createInput.text);
    }

    public void JoinRoom()
    {
        PhotonNetwork.JoinRoom(joinInput.text);
    }

    public override void OnJoinedRoom()
    {
        PhotonNetwork.LoadLevel("SampleScene");

        Player = GameObject.Find("Player");

        DontDestroyOnLoad(PhotonNetwork.Instantiate("Player", new Vector3(-3, -5, 0), Quaternion.identity, 0));

        if (Player.activeInHierarchy)
        {
            DontDestroyOnLoad(PhotonNetwork.Instantiate("Player2", new Vector3(3, -5, 0), Quaternion.identity, 0));
        }
    }
}
#

is there another way to check if the first Player was instantiated.

river meteor
#

yes it its

#
GameObject spawnedPlayer = PhotonNetwork.Instantiate(...);
if(spawnedPlayer==null)
Debug.LogError("Player IS NOT SPAWNED!");
#

for ex

placid oak
#

what is the basic idea of having an authoritive server with photon... how woould i implement that ... like just the basic idea

ornate zinc
placid oak
#

the basic idea of a NON authoritive server would be
-> user presses W -> user moves char -> server synchronizes

the basic idea of an authoritive server would be
-> user presses W -> sends request to server -> server checks if possible -> server synchronises the result

#

so how does it work to implement the authortive server in photon

#

is there a tutorial or anything

#

like "hackers" just tell the server 10 times per frame that they jumped => fly "hack"... its just the server didnt check if they are allowed to jump yet

#

hope it got more clear what i mean

ornate zinc
#

Hm, I mean as long as your game is written correctly, how should a "hacker" be able to tell the server that they jumped 10 times if your code prevents you from jumping? just wondering

placid oak
#

if you have authoritive server it doesnt matter anymore if its reworked or not

#

you allow on the server the normal gameplay and "everything" (there is always something not perfect)

#

else gets blocked

ornate zinc
#

If someone really takes the effort of doing this, well, credits to them ๐Ÿ˜„ but yeah, if you want to have it 100% proof, photon themselves say that a full autority server isnt their thing, but you can always just check the values the players position is sending and check for weird offsets and stuff

placid oak
#

photon themselves say that a full autority server isnt their thing,

How do you mean that

ornate zinc
#

last section

jovial pike
#
public override void OnJoinedRoom()
    {
        PhotonNetwork.LoadLevel("SampleScene");

        if (once == true)
        {
            GameObject Player = PhotonNetwork.Instantiate("Player", new Vector3(-3, -5, 0), Quaternion.identity, 0);
            DontDestroyOnLoad(Player);
            once = false;
        }
        else if (Player != null)
        {
            DontDestroyOnLoad(PhotonNetwork.Instantiate("Player2", new Vector3(3, -5, 0), Quaternion.identity, 0));
            DontDestroyOnLoad(Player);
        }
    }
placid oak
#

ok where is now the difference between photon bolt and normal photon?

jovial pike
#

i want to give up ๐Ÿ˜ฆ

#

its too hard

jovial pike
#

for both players

ornate zinc
#

you are setting your once stuff only on one client

placid oak
#

like 1 bit... ... was a joke... yeaah

jovial pike
#

and why is it so laggy?

#

can i fix that?

ornate zinc
# jovial pike can i fix that?

Welcome to network gaming, if your ocnnection sucks or your friends' connection or both, it will lag. Also depends on your whole game how much data you are sending over the network

jovial pike
#

my game is very small

#

and i dont think that my internet is bad

ornate zinc
#

I dont know about your network, but laggy is either network connection, too much data or photon is giving free service which will limit bandwidth

placid oak
#

i got the free standalone

#

version of unity

placid oak
#

i got pc mac linux standalont 2020.3.9f1 Personal

ornate zinc
placid oak
#

like idk if my unity version works with photon bolt

ornate zinc
#

Well i guess its a minimum requirement.

placid oak
#

look here at the section unity API

#

i dont get whats writen there ...

ornate zinc
#

It might be just old

placid oak
#

so ye another question came up...

why do so many use the low level api PUN when bolt is available...

like selfmade room management is always a source for errors and problems and a high level api gives you much more stuff by default

ornate zinc
#

tbh, I dont know. I guess most tutorials just start with photon out of the box and not bolt, just a guess

burnt axle
#

Is it better to use frameworks/services like Photon server f.ex. for MMO games or just build your own backend? I guess services takes care of a lot of the infrastructures like load balancing f.ex. which makes it convenient

ornate zinc
#

If you are not a network expert, dont even think about doing your own hacky network thing ๐Ÿ˜‰

jovial pike
#

should I remove Photon from my project if I no longer use it?

ornate zinc
#

Should I remove my garbage from my car if I dont need it? you dont have to, but it will make things messy ๐Ÿ˜„

jovial pike
#

ok thx

placid oak
jovial pike
#

but i mean the Package Photon

#

for some reason i thought my unity would run slower if i kept it in my project

placid oak
spring crane
# placid oak so ye another question came up... why do so many use the low level api PUN when...

While it's easier to get higher quality networking through the higher end Photon products, they require you to learn more stuff to make sure you are using the facilities provided by the framework. Recommending a more complex product to someone who doesn't know what problems they are trying to solve is probably not ideal.
From Photon Bolt's description:

Bolt is the perfect product for professional developers and experienced teams. It provides all these teams need to build the next PUBG or Fortnite.
Bolt is rather not suited for beginners. Developing a multiplayer game requires profound coding knowledge especially in case of an authoritative game server architecture.

#

IIRC Photon Quantum is gated from the public partially for similar reasons, as there are even more things going on and it's expected that you work with ExitGames to some extent.

#

Users looking into Photon Bolt should probably look into Photon Fusion too btw.

weak plinth
#

is there a good way to set up a chat system using mlapi

echo garnet
#

When i use photon pun my active ragdolls break like this anyone know why?

echo garnet
#

update the ragdolls parts aren't synced
its a bit weird
anyone know why this is happening with photon?

inland sand
echo garnet
#

photon transform view classic

inland sand
#

on the parent gameobject or every part of the body?

echo garnet
echo garnet
#

should I use photon transform view?

#

or photon transform view classic ?

inland sand
#

both works the same way ig

echo garnet
proper sphinx
#

could anyone help me with an issue i've been having? when another player connects to the game, player 1 controls player 2's character and vice versa. i'm using photon

lavish forge
#

Hey, I am making a game with photon pun and the player is able to join rooms and while waiting in the room before a game starts, the player gets to an other scene. But if the player leaves the room and joins a new room, I need a function that will be called because the Start function is only run at the first scene start. How can I do this?

prime dawn
#

I've started my FPS project a while ago and it's pretty developed at this point but the problem is I was using PUN whole this time. Now that I've realised bolt is a thing, do you think switching PUN to bolt will be hard?

stiff ridge
# echo garnet I tried only the parent as well and its still broken

To sync an active ragdoll, I think I would come up with a replacement of the PhotonTransformView. Or at least I would suggest to write one component which aggregates the complete ragdoll into one update / byte[] and then send it along with the rest of the values (via OnPhotonSerializeView). The benefit would be that you have one component which produces a fixed result. A snapshot, which is what you want to sync.
Also, you have to disable the active ragdoll system on the clients just showing the remote character. Otherwise the local machine will apply a ragdoll solution and it "fights" the incoming updates.
And this leads to the other solution: You could possibly skip syncing the ragdoll and just have every client calculate the movement, according to local and incoming movement.

#

Putting a PhotonView on each node is adding a lot of useless overhead and you only sync positions and nothing more. When you write your own component, you can send velocities and other useful data (as you see fit).

stiff ridge
stiff ridge
proper sphinx
#

thank you for your help :)

stiff ridge
proper sphinx
stiff ridge
proper sphinx
#

if only one player joins the room, the player character works completely fine

#

as soon as another joins, when you try to look around/move, your character doesn't but you can see from the other screen that those inputs are being applied to the other player's character

#

if that makes sense

stiff ridge
#

well, i get that something is odd but .. it does not make sense ๐Ÿ™‚
it's not just that you forgot to click the window to make it the one to get input from the machine? (sorry, stupid question...)

proper sphinx
#

yeah it's really weird - and, no, i'm certain it's not because i forgot to click! but it would have been funny if that was the issue haha

#

i think i'll start a new project and chalk that first one down to experience. if it doesn't work on the next project, i'll come back and see if anyone has any ideas

stiff ridge
#

Do both players use PhotonNetwork.Instantiate() to get an instance of a prefab?

echo garnet
#

I dunno how to rly do that

river meteor
cunning sluice
#

In PUN2 I have two cubes stacked. When I have one cube on top owned by one person, and the bottom one owned by another person. The cube on top begins slightly moving on its own even though the bottom object isn't moving. This doesn't happen when both objects are owned by the same person. Anyone have a solution? I've been on this for 5 hours trying all sorts of things.

Any help would be extremely appreciated

robust cypress
#

Hey, I am using Photon Pun to make a fast paced pvp 2D platformer.
I was wondering what approach to the networking do you recommend when syncing movement.

cunning sluice
#

You're probably just getting a photo view in general, not their photon view specifically

normal marsh
#

Hello, im using Photon 2 (PUN) to make a multiplayer game. Im trying to get all the rooms in a lobby then put them in a grid. I got it working, but i want it to refresh when you open the main menu scene. So I want to call the "OnRoomListUpdate" using the "PhotonNetwork.GetCustomRoomList" function, but i dont know what to put in the "sqlLobbyFilter" parameter. I just want to display ALL the rooms in the current lobby, what should i put in the "sqlLobbyFilter" parameter?

cunning sluice
#

also you probably wouldn't need to put anything important in the lobby filter

#

Just calling GetCustomRoomList will call the onroomlistupdate

#

so as long as all your room listings are handled in OnRoomListUpdate, I believe it'll just automatically refresh all the rooms like it does the first time

#

otherwise the leavelobby and join lobby is always an option I've never had trouble with'

#

Well I guess the lobby thing wouldn't be the best if you're having players in specific lobbies for specific reasons

#

in my case I just have a main area where I list the servers and you don't invite people to your lobby etc

normal marsh
cunning sluice
#

but I guess the lobby really is just a place beforehand so you can always have them be in a room together etc

normal marsh
#

@cunning sluice Thanks a ton! I just moved the join lobby function from my loading scene to my main menu scene. Now the rooms refreshes when i load in. Thanks for the help!

valid totem
#

Hi, does anyone have any experience with matchmaking and MLAPI, im trying to use the MLAPI Relay but after building and running and setting the network manager to use the relay, im not sure where to go from here. The details on the wiki are sparce, so any pointers would be grealy appreciated ๐Ÿ˜„

stable igloo
valid totem
#

Mirror is similar to MLAPI, right?

prime dawn
#

I'm getting this error, which is weird because it doesn't show anywhere how my scripts caused that error.

#

it only takes me to photon's script

#

my scripts are nowhere to be seen here

#

let's see if rebuilding the solution helps

#

or whatever this button does

spring crane
#

Are you changing ownership in script?

prime dawn
#

not at all

#

but maybe it's because I was using an old build

spring crane
#

Does this happen when masterclient changes or something?

#

Oh it doesn't happen anymore?

prime dawn
#

I don't know yet

#

I'm making a new build

#

just to be sure

#

but it was occuring when I was automatically joining an existing lobby

#

or room

#

ah....

#

still the same

#

It started happening when I changed my joining script

#

let me make a ss

spring crane
#

What was the change?

prime dawn
#

well, before it showed a list of available rooms

#

now I just made it a single click

spring crane
#

Hmm, maybe there is a timing bug there. Are you on the latest version of PUN?

prime dawn
#

yeah

#

updated it recently

spring crane
#

How are you spawning objects? Do you have scene objects with photonviews?

prime dawn
#

it works for the host

#

but I can't join that lobby

spring crane
#

How are you joining that room?

prime dawn
#
JoinRandomRoom();```
#

but the host creates it of course

spring crane
#

How are the player objects created?

#

Or is it not getting that far?

prime dawn
spring crane
#

Issue with loading/syncing the scene perhaps, which could cause missing photonviews?

#

Does it error before OnClick_StartGame()?

prime dawn
#

yes

#

and the error shows for the person that is trying to join

#

and before startgame() no scenes are switched

spring crane
#

I would probably look into what viewids are being processed in that photon code

prime dawn
#

but if you are single, just create a room, start the game

#

no errors appear

spring crane
#

Would also start the process of eliminating everything that isn't necessary to see where the issue might be

#

You might get better troubleshooting steps in the Photon discord

prime dawn
#

I tried finding one, but those are usually small

spring crane
#

Yes, but full of Photon employees ๐Ÿ˜›

prime dawn
#

I couldn't find the official one

spring crane
#

You are in it

prime dawn
#

AM I

#

OH

#

btw this is my version

#

that's the newest one...

spring crane
#

Yea mention it in the post

prime dawn
#

well.. it's my time to sleep anyways

#

will see if I can fix it tommorow

#

thank you for your help

#

the staff is AFK love it xD

spring crane
#

It's not always about quantity and speed, but quality ๐Ÿ˜‰

echo garnet
#

Do you have a link? Im just a bit confused lol

spring crane
#

IIRC they actually don't have a code example in the doc. Odds are it's clearer to just open the transform sync component to see how it's done

cunning sluice
#

In PUN2 I have two cubes stacked. When I have one cube on top owned by one person, and the bottom one owned by another person. The cube on top begins slightly moving on its own even though the bottom object isn't moving. This doesn't happen when both objects are owned by the same person. Anyone have a solution? I've been on this for 5 hours trying all sorts of things.

Any help would be extremely appreciated

onyx spire
#

I'm using SceneManager.LoadScene(0) to reload my scene, but just before doing that, I first close my TcpClient connection using .Close(), however, after the scene reloads, if I create a new TcpClient it works fine but a NetworkStream does not work, it doesn't give me any errors but it also doesn't send or receive any data for some reason. Does anyone know how to fix this issue, or reload a scene in a way which completely resets any socket state? (The socket is closed before reloading and a new one is made later so there should be no problem)

#

I'm also 100% sure it isn't a problem with the server.

spring crane
#

Worth noting that the only things Unity can affect are its engine objects. Any C# change is merely a side effect of it through garbage collector. If you are holding references to stuff somewhere, you might not be fully releasing stuff

onyx spire
#

Hmm I see, thanks
I'll test some things out in the morning and make sure the socket connection is actually being terminated properly

echo garnet
river meteor
#

I think so

proper sphinx
lofty cedar
#

hey what if i use only hubs on layer 2 what will happens on my network

stiff ridge
# cunning sluice In PUN2 I have two cubes stacked. When I have one cube on top owned by one perso...

This is likely the physics engine and the network updates getting in a fight over where things should be precisely.
It's enough if the network updates of a remote-owned cube put it minimally into the local cube to freak out the physics. Stacking is problematic in networked physics.
It may be enough to turn on isKinematic on the remote cubes but it might be better to have both cubes controlled by one player (and one physics engine).

novel topaz
#

Hello, i have a very very strange problem. I upgraded my mirror project from 2019.3 to 2020.3.4 and there is one very very strange issue.
When i click "host & client" in the mirror default HUD, my game scene is launched and my player is supposed to spawn in my spawnpoint , this is the case BUT he is strangely bounced forward, exactly as if another player was at the exact same position so the new player is bounced forward to avoid them to intersect. But the problem is that there isn't another player ! When i try to go back on the spawnpoint by moving my player, there is exactly an "invisible" collider (same size as my player collider) which avoid my player to go on this position. But once again, there isn't any other player.
Thats realy strange, since the only cause is that I've upgraded to 2020.3
In the hierarchy there isn't ANY object here, nor in the wireframe scene view. It's totaly wtf. Even if i unactive all the object except my player i can't go in this position...
Anybody have an idea for this very strange problem ?

cunning sluice
#

Would it be best to get an authoritative server?

weak plinth
#

Hi, im new to networking, and i wanna make a game like Operation Tango. Does anyone know how to make the two player only lobby with password kinda system? Or can recommend a good Tutorial? I looked into it and it confuses me what to use (MLAPI, Photon, Mirror, etc)

hasty wyvern
# weak plinth Hi, im new to networking, and i wanna make a game like Operation Tango. Does any...

Hey! I just started making games as well. I am making a multiplayer 3D puzzle game and i have been using Photon. Itโ€™s pretty easy to use and there are a lot of tutorials. Iโ€™d recommend looking up โ€œunity photonโ€ on YouTube and just kinda looking around. Depending on what game you make can vary the tutorial. Hope this helps lmk if you need any more ideas or have questions

stiff ridge
spring cargo
#

Hi

#

Could anyone please help me with UDP connection?

#

I am trying to create a remote for my standalone application. Created a UDP client to send values, it works fine on editor but not working on build.

#

logcat shows no error. But I am not receiving any data send by the sender (mobile application)

#

Thanks in advance,

upper root
#

is it a reasonable task to Play two instances of the game while still in the Editor, for the sake of multiplayer testing?

haughty heart
#

It's not possible, if that's what you're asking.

#

You need to build it and run the build and editor together.

gleaming prawn
#

It is possible, just depends on the sdk you use

#

Photon quantum and photon fusion both have this as a built in option

upper root
upper root
verbal lodge
#

You can also checkout ParrelSync which allows you to run two editors of the same project at the same time.

upper root
restive geode
#

Is there a callback function when the user connects and disconnects from the internet? At the moment I'm using an update loop to check if the user is able to reach the internet and if so it does some code.

echo garnet
#

I have a error that says

InvalidCastException: Specified cast is not valid. PUN2_RigidbodySync.OnPhotonSerializeView (Photon.Pun.PhotonStream stream, Photon.Pun.PhotonMessageInfo info) (at Assets/PUN2_RigidbodySync.cs:37) Photon.Pun.PhotonView.DeserializeComponent (UnityEngine.Component component, Photon.Pun.PhotonStream stream, Photon.Pun.PhotonMessageInfo info) (at Assets/Photon/PhotonUnityNetworking/Code/PhotonView.cs:544) Photon.Pun.PhotonView.DeserializeView (Photon.Pun.PhotonStream stream, Photon.Pun.PhotonMessageInfo info) (at Assets/Photon/PhotonUnityNetworking/Code/PhotonView.cs:534) Photon.Pun.PhotonNetwork.OnSerializeRead (System.Object[] data, Photon.Realtime.Player sender, System.Int32 networkTime, System.Int16 correctPrefix) (at Assets/Photon/PhotonUnityNetworking/Code/PhotonNetworkPart.cs:1860) Photon.Pun.PhotonNetwork.OnEvent (ExitGames.Client.Photon.EventData photonEvent) (at Assets/Photon/PhotonUnityNetworking/Code/PhotonNetworkPart.cs:2231) Photon.Realtime.LoadBalancingClient.OnEvent (ExitGames.Client.Photon.EventData photonEvent) (at Assets/Photon/PhotonRealtime/Code/LoadBalancingClient.cs:3356) ExitGames.Client.Photon.PeerBase.DeserializeMessageAndCallback (ExitGames.Client.Photon.StreamBuffer stream) (at D:/Dev/Work/photon-dotnet-sdk/PhotonDotNet/PeerBase.cs:898) ExitGames.Client.Photon.EnetPeer.DispatchIncomingCommands () (at D:/Dev/Work/photon-dotnet-sdk/PhotonDotNet/EnetPeer.cs:565) ExitGames.Client.Photon.PhotonPeer.DispatchIncomingCommands () (at D:/Dev/Work/photon-dotnet-sdk/PhotonDotNet/PhotonPeer.cs:1863) Photon.Pun.PhotonHandler.Dispatch () (at Assets/Photon/PhotonUnityNetworking/Code/PhotonHandler.cs:221) Photon.Pun.PhotonHandler.FixedUpdate () (at Assets/Photon/PhotonUnityNetworking/Code/PhotonHandler.cs:147)

#
public class PUN2_RigidbodySync : MonoBehaviourPun, IPunObservable
{

    Rigidbody2D r;

    Vector3 latestPos;
    Quaternion latestRot;
    Vector3 velocity;
    Vector3 angularVelocity;

    bool valuesReceived = false;

    // Start is called before the first frame update
    void Start()
    {
        r = GetComponent<Rigidbody2D>();
    }

    public 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(r.velocity);
            stream.SendNext(r.angularVelocity);
        }
        else
        {
            //Network player, receive data
            latestPos = (Vector3)stream.ReceiveNext();
            latestRot = (Quaternion)stream.ReceiveNext();
            velocity = (Vector3)stream.ReceiveNext();
            angularVelocity = (Vector3)stream.ReceiveNext();

            valuesReceived = true;
        }
    }

    // Update is called once per frame
    void Update()
    {
        if (!photonView.IsMine && valuesReceived)
        {
            //Update Object position and Rigidbody parameters
            transform.position = Vector3.Lerp(transform.position, latestPos, Time.deltaTime * 5);
            transform.rotation = Quaternion.Lerp(transform.rotation, latestRot, Time.deltaTime * 5);
            r.velocity = velocity;
            r.angularVelocity = angularVelocity.magnitude;
        }
    }

    void OnCollisionEnter(Collision contact)
    {
        if (!photonView.IsMine)
        {
            Transform collisionObjectRoot = contact.transform.root;
            if (collisionObjectRoot.CompareTag("Player"))
            {
                //Transfer PhotonView of Rigidbody to our local player
                photonView.TransferOwnership(PhotonNetwork.LocalPlayer);
            }
        }
    }
}```
#

This is my code for syncing rigidbodys ^^

#

Anyone know whats wrong

limber holly
#

hello, Im working on my enemy detection, I wonder in a light 2D mmorpg what's the best way ?in my current system, I have a player list in the scene and my enemies have DetectPlayer fonction. But it means all enemies checking a list of Playerscript every second. Is it a good way or is it too heavy ? thanks

jaunty veldt
#

@echo garnet
May I asked why View ownership is transferred on collison?

#

Also make sure to ping me because I have this server muted

inland sand
#

i am using mirror for my multiplayer and for some reason I can't connect to my friend (not on lan) with his ip address, is there a way I could connect with him and play?

wind hinge
#

does anybody know how to make a kill counter using photon? i use raycasts to take damage to others btw. the raycast instantiate a bullet image that becomes a child of an object.

weak plinth
#

trying to make a pause menu in unity using photon, but whenever i press the menu button to go back it i get these errors and the menu stays on the loading screen:

#

and when i double click on it, it takes me to this code:

#

i dont see where the menu is being destroyed, can anyone help me?

wind hinge
#

lol i think i have followed the same tutorials as you have

sullen turtle
#

I'm working on a mobile game, right now focused on Android and i have the basics of a level creator, every level is encoded as a base64 string, up to 80 characters long, and i want a way to let people share their levels with others, i only need to store that single string, and possibly some metadata about likes and dislikes of the level, which can just be 2 integers stored alongside it, im looking for a service that would let me store this data in a central repository to easily and quickly grab from, if possible for free, or atleast for very cheap
any recommendations/resources?

wind hinge
#

no idea

echo garnet
#

where does it say?

echo garnet
#

I still dunno what this means tho InvalidCastException: Specified cast is not valid. PUN2_RigidbodySync.OnPhotonSerializeView (Photon.Pun.PhotonStream stream, Photon.Pun.PhotonMessageInfo info) (at Assets/PUN2_RigidbodySync.cs:37) Photon.Pun.PhotonView.DeserializeComponent (UnityEngine.Component component, Photon.Pun.PhotonStream stream, Photon.Pun.PhotonMessageInfo info) (at Assets/Photon/PhotonUnityNetworking/Code/PhotonView.cs:544) Photon.Pun.PhotonView.DeserializeView (Photon.Pun.PhotonStream stream, Photon.Pun.PhotonMessageInfo info) (at Assets/Photon/PhotonUnityNetworking/Code/PhotonView.cs:534) Photon.Pun.PhotonNetwork.OnSerializeRead (System.Object[] data, Photon.Realtime.Player sender, System.Int32 networkTime, System.Int16 correctPrefix) (at Assets/Photon/PhotonUnityNetworking/Code/PhotonNetworkPart.cs:1860) Photon.Pun.PhotonNetwork.OnEvent (ExitGames.Client.Photon.EventData photonEvent) (at Assets/Photon/PhotonUnityNetworking/Code/PhotonNetworkPart.cs:2231) Photon.Realtime.LoadBalancingClient.OnEvent (ExitGames.Client.Photon.EventData photonEvent) (at Assets/Photon/PhotonRealtime/Code/LoadBalancingClient.cs:3356) ExitGames.Client.Photon.PeerBase.DeserializeMessageAndCallback (ExitGames.Client.Photon.StreamBuffer stream) (at D:/Dev/Work/photon-dotnet-sdk/PhotonDotNet/PeerBase.cs:898) ExitGames.Client.Photon.EnetPeer.DispatchIncomingCommands () (at D:/Dev/Work/photon-dotnet-sdk/PhotonDotNet/EnetPeer.cs:565) ExitGames.Client.Photon.PhotonPeer.DispatchIncomingCommands () (at D:/Dev/Work/photon-dotnet-sdk/PhotonDotNet/PhotonPeer.cs:1863) Photon.Pun.PhotonHandler.Dispatch () (at Assets/Photon/PhotonUnityNetworking/Code/PhotonHandler.cs:221) Photon.Pun.PhotonHandler.FixedUpdate () (at Assets/Photon/PhotonUnityNetworking/Code/PhotonHandler.cs:147)

silver rune
#

Guys how come yesterday i used networkBehaviour and it said it was obsolete but still ran fine but now today i keep the same stuff and it isnt running at all?

olive vessel
#

Are you using UNET?

silver rune
#

yesterday i did

#

and it worked

olive vessel
#

Jesus fuck why

#

UNET was deprecated over 2 years ago

silver rune
#

idk how to use other things and no one really answers my questions they just say look at the api

olive vessel
#

There are tonnes of tutorials for Mirror and Photon

#

Few good ones for Unity's new solution. MLAPI

silver rune
#
using UnityEngine;
using UnityEngine.Networking;

public class PlayerSetup : NetworkBehaviour {

    [SerializeField]
    Behaviour[] componentsToDisable;

    Camera sceneCamera;

    void Start()
    {
        if (!isLocalPlayer)
        {
            for (int i = 0; i < componentsToDisable.Length; i++)
            {
                componentsToDisable[i].enabled = false;
            }
        }
        else
        {
            sceneCamera = Camera.main;
            if (sceneCamera != null)
            {
                sceneCamera.gameObject.SetActive(false);
            }
        }
    }

    void OnDisable()
    {
        if (sceneCamera != null)
        {
            sceneCamera.gameObject.SetActive(true);
        }
    }
}
#

like for example how would i make that now days?

olive vessel
#

Firstly, get a new solution

silver rune
#

ill use mlapi

olive vessel
#

Ok, it's pretty new but I liked it when I tried it

#

There's a couple of good tutorials for it too

silver rune
#

ok thankyou ill look at it it wouldnt be hard to re do that script in mlapi right?

olive vessel
#

You need a different using directive, and I think in MLAPI IsLocalPlayer is capitalised

#

Aside from that, that script should work

silver rune
#

really?

#

whats the directive?

#

like

olive vessel
#

MLAPI

silver rune
#

networkBehaviour?

olive vessel
#

No

#

Using directives are those using tags

silver rune
#

so i change networkBehaviour to mlapi

olive vessel
#

No

silver rune
#

oh ok

#

is networkBehaviour fine?

olive vessel
#

It's NetworkBehaviour, but yes

silver rune
#

ok do you know what the tag is?

olive vessel
#

?

silver rune
#

using unity.MLAPI?

olive vessel
#

You do need to install it though, it's not built in

silver rune
#

oh ok thankyou!

jaunty veldt
#

@echo garnet it says that there is an invalid cast on line 37 of that script.

#

Could you send the script again by any chance and outline what is line 37?

echo garnet
#

this is line 37

spring crane
#

For a 2D RB, most likely

#

Hover over the field you are sending to see its type

jaunty veldt
#

@echo garnet if it's a Rigidbody2D then yes, that's probably the issue :)

echo garnet
#
{

    Rigidbody2D r;

    Vector2 latestPos;
    Quaternion latestRot;
    Vector2 velocity;
    Vector2 angularVelocity;

    bool valuesReceived = false;

    // Start is called before the first frame update
    void Start()
    {
        r = GetComponent<Rigidbody2D>();
    }

    public 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(r.velocity);
            stream.SendNext(r.angularVelocity);
        }
        else
        {
            //Network player, receive data
            latestPos = (Vector2)stream.ReceiveNext();
            latestRot = (Quaternion)stream.ReceiveNext();
            velocity = (Vector2)stream.ReceiveNext();
            angularVelocity = (Vector2)stream.ReceiveNext();

            valuesReceived = true;
        }
    }

    // Update is called once per frame
    void Update()
    {
        if (!photonView.IsMine && valuesReceived)
        {
            //Update Object position and Rigidbody parameters
            transform.position = Vector2.Lerp(transform.position, latestPos, Time.deltaTime * 5);
            transform.rotation = Quaternion.Lerp(transform.rotation, latestRot, Time.deltaTime * 5);
            r.velocity = velocity;
            r.angularVelocity = angularVelocity.magnitude;
        }
    }
}```
#

this is the code does it look good?

jolly wadi
jolly wadi
jaunty veldt
jaunty veldt
echo garnet
#

But i assume that switcing to vector2 will work

jaunty veldt
#

@echo garnet
latestRot should be a float not a quaternion
also instead of sending transform.position and transform.rotation you should send r.position and r.rotation

#

Because transform.position is a vector3 not a vector2, and transform.rotation is a quaternion while r.angularVelocity is a float

#

Wait hold up I'll fix the script in Visual Studio for you

#

@echo garnet

using UnityEngine;

public class PUN2_RigidbodySync : MonoBehaviourPun, IPunObservable
{

    Rigidbody2D r;

    Vector2 latestPos;
    float latestRot;
    Vector2 velocity;
    float angularVelocity;

    bool valuesReceived = false;

    // Start is called before the first frame update
    void Start()
    {
        r = GetComponent<Rigidbody2D>();
    }

    public void OnPhotonSerializeView(PhotonStream stream, PhotonMessageInfo info)
    {
        if (stream.IsWriting)
        {
            //We own this player: send the others our data
            stream.SendNext(r.position);
            stream.SendNext(r.rotation);
            stream.SendNext(r.velocity);
            stream.SendNext(r.angularVelocity);
        }
        else
        {
            //Network player, receive data
            latestPos = (Vector2)stream.ReceiveNext();
            latestRot = (float)stream.ReceiveNext();
            velocity = (Vector2)stream.ReceiveNext();
            angularVelocity = (float)stream.ReceiveNext();

            valuesReceived = true;
        }
    }

    // Update is called once per frame
    void Update()
    {
        if (!photonView.IsMine && valuesReceived)
        {
            //Update Object position and Rigidbody parameters
            transform.position = Vector2.Lerp(transform.position, latestPos, Time.deltaTime * 5);
            transform.rotation = Quaternion.Lerp(transform.rotation, latestRot, Time.deltaTime * 5);
            r.velocity = velocity;
            r.angularVelocity = angularVelocity.magnitude;
        }
    }
}
#

This should be fine

limber holly
#

I was wondering if UI (healthBar, minimap etc) is A GameObject I have to add to the game scene, or if I have to place it in the Player GO ?

oak yacht
#

Is it possible to schedule network requests on background threads rather than main thread? I'm currently using coroutines but am experience bursts of lag when many requests are being sent

#

I know Unity has a Job system to do true multithreading but I don't understand it enough yet to determine if it could be used for networking

spring crane
limber holly
#

@spring craneok then, I Instantiate this UI in the same Fonction of my player ?

spring crane
#

Yea that is fine. I generally manage them separately

haughty inlet
#

is making fast and reliable networking for a 2D pvp shooter game as an indie dev that impossible?

wind hinge
#

can anybody help me with why i cant leave a room in photon

#

this is my code:

#

//this VOID is called when the UI leave button is pressed btw
public void Leave()
{
PhotonNetwork.LeaveRoom();
Debug.Log("left room");
}
public override void OnLeftRoom()
{
PhotonNetwork.LoadLevel("mainMenu");
Debug.Log("switched scene");
base.OnLeftRoom();
}

#

it doesnt switch scene

#

the game just freezes

modern drift
#

hey, I'm new to networking and I've been watching some mirror tutorials. But some things seem weird to me. I sort of understand how client sends messages to server and vice versa. But in all tutorials they seem to be going for a messy approach where the client and server code are on the same script. i understand this is because there can be a client and server together, but why can't this be split apart to different scripts? does anybody have a different way of doing this?

junior willow
# modern drift hey, I'm new to networking and I've been watching some mirror tutorials. But som...

Client and server code are on the same script because both the client and server have their own instance of that GameObject, so if you'd like to think of it this way, the player is technically communicating with itself, but just on different instances of itself. So if I have movement code controlled by the client, you ask the server to move that same client, but instead it's the server's instance. You could create a GameManager script that has a singleton that allows your client to pass in your current client's id, then the GameManager does the server request. But just make sure that the client code is always on the client itself, and ANY networking code is on a NetworkBehaviour object

cinder sluice
#

Hey does anyone know off the bat how I should go about making it so that in my multiplayer game that everyone downloads an asset bundle? like for custom player clothing and whatnot
I'm using socketweaver for the actual multiplayer

echo garnet
#

it gives me errors

#

saying it can't convert float to quaertion

#

on this one transform.rotation = Quaternion.Lerp(transform.rotation, latestRot, Time.deltaTime * 5);

#

and how float doesn't cotain a defintion for magitude on this line r.angularVelocity = angularVelocity.magnitude;

olive vessel
echo garnet
#

this is my script for syncing rigidbodys but it still just doesn't work ```public class PUN2_RigidbodySync : MonoBehaviourPun, IPunObservable
{

Rigidbody2D r;

Vector2 latestPos;
Quaternion latestRot;
Vector2 velocity;
Vector2 angularVelocity;

bool valuesReceived = false;

// Start is called before the first frame update
void Start()
{
    r = GetComponent<Rigidbody2D>();
}

public 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(r.velocity);
        stream.SendNext(r.angularVelocity);
    }
    else
    {
        //Network player, receive data
        latestPos = (Vector2)stream.ReceiveNext();
        latestRot = (Quaternion)stream.ReceiveNext();
        velocity = (Vector2)stream.ReceiveNext();
        angularVelocity = (Vector2)stream.ReceiveNext();

        valuesReceived = true;
    }
}

// Update is called once per frame
void Update()
{
    if (!photonView.IsMine && valuesReceived)
    {
        //Update Object position and Rigidbody parameters
        transform.position = Vector2.Lerp(transform.position, latestPos, Time.deltaTime * 5);
        transform.rotation = Quaternion.Lerp(transform.rotation, latestRot, Time.deltaTime * 5);
        r.velocity = velocity;
        r.angularVelocity = angularVelocity.magnitude;
    }
}

}```

#

my ragdoll still break to pieces

#

and i feel like giving up on the project i've been stuck for days

echo garnet
#

its stuck like this

#

just broken

#

I have a error that says InvalidCastException: Specified cast is not valid.

#

On this line velocity = (Vector2)stream.ReceiveNext();

river meteor
#

try to receive it as Vector3 not Vector2

#

I don't know I had similar problem with this error when I dont even made a changes in serializing values and unity restart was the solution

oak yacht
#

Is it possible to schedule network requests on background threads rather than main thread? I'm currently using coroutines but am experience bursts of lag when many requests are being sent. I know Unity has a Job system to do true multithreading but I don't understand it enough yet to determine if it could be used for networking

oak yacht
#

Context: every one of my NPCs runs this code when it's their turn to talk in a conversation

oak yacht
#
 void Update()
    {
        int index = -1;
        if (conversation != null)
        {
            if (!conversation.processing)
            {
                if (conversation.currentSpeaker.Equals(this.id))
                {
                    Debug.Log(this.id + " getting response");
                    conversation.processing = true;
                    StartCoroutine(getResponse(conversation));
                }
            }
        }
        else if (Datastore.Instance.id2conversation.TryGetValue(id, out index))
        {
            conversation = Datastore.Instance.conversations[index];
        }

    }```
#
    IEnumerator getResponse(Conversation conversation)
    {
        WWWForm form = new WWWForm();
        form.AddField("id", this.id);

        var www = UnityWebRequest.Post("http://" + Datastore.Instance.host + ":3000/generate", form);

        yield return www.SendWebRequest();

        if (interrupted) yield break;

        if (www.isNetworkError)
        {
            Debug.Log(www.error);
        }
        else
        {
            if (www.GetResponseHeaders().Count > 0)
            {
                var jsonData = JSON.Parse(www.downloadHandler.text);

                string stringData = jsonData["audioContent"]["data"].ToString();
                byte[] rawdata = AudioHelpers.ConvertToByteStream(stringData);

                AudioClip clip = AudioHelpers.ConvertToAudioClip(rawdata);

                this.audioSource.clip = clip;
                this.audioSource.Play();

                this.animator.SetBool(this.talkingBoolHash, true);

                Debug.Log("Response Recieved");

                yield return new WaitForSeconds(clip.length);

                if (interrupted) yield break;

                this.conversation.currentSpeaker = jsonData["nextSpeaker"].ToString().Replace("\"", "");
                this.conversation.processing = false;
                this.animator.SetBool(this.talkingBoolHash, false);
            }
        }
    }```
cedar cloak
#

Does Photon PUN automatically reassign the Master if the current one leaves?

echo garnet
river meteor
short island
#

i recommend photon realtime

#

instead

#

once you get your head around that and write your own wrapper it is a lot better

#

i have used both

#

super friends party uses pun and it was a nightmare compared to realtime

signal halo
#

hi gys how i can make gRPC Server incloud unity by ASP.netCore

echo garnet
echo garnet
short island
# echo garnet Uhh me?

depends on your programming knowledge but with an intermediate skill set it is less annoying than PUN

river meteor
silver rune
#

can someone who knows what they're doing with MLAPI and networking please vc with me cause i have a problem which is very strange and alot of people have tried helping with no success

west quarry
#

hi, i am using photon 2 and whenever i want to do an action that affects all players i have to do it this way, do you know a shorter way? ```
//Activa y desactiva coche
public void SetActiveCoche(bool _active)
{
if (PhotonNetwork.IsConnectedAndReady)
{

        photonView.RPC("SetActiveCocheRPC", RpcTarget.MasterClient, _active);
    }
    else
    {
        SetActiveCocheRPC(_active);
    }
}

[PunRPC]
public void SetActiveCocheRPC(bool _active)
{
    Debug.Log(_active + "coche");
}

//Activa y desactiva cube
public void SetActiveCube(bool _active)
{
    if (PhotonNetwork.IsConnectedAndReady)
    {

        photonView.RPC("SetActiveCubeRPC", RpcTarget.MasterClient, _active);
    }
    else
    {
        SetActiveCubeRPC(_active);
    }
}

[PunRPC]
public void SetActiveCubeRPC(bool _active)
{
    Debug.Log(_active + "cube");
}```
olive vessel
#

Might I also point out, that you are not in the best place for help regarding MLAPI, they have a Discord server

weak plinth
#

so i'm using fizzysteamworks and mirror attempting to make multiplayer

#

i have made it so that i can make a host, and join the host through steam on another device

#

and i have a basic movement script that moves both player prefabs randomly around a cerrtain area

#

problem is that the players' transform is not synced between the host and client, even after adding a networktransform component to the player prefab

green tide
#

How would a non player object spawn a bullet?

olive vessel
green tide
#

Mirror

green tide
#

Ive already through that. So I need to spawn the bullet from a method from the network manager?

#

So the enemy then calls this method, in order to spawn a bullet?

olive vessel
#

You'd call a method to spawn the bullet on the server

green tide
#

And this method has to be in the NetworkManager script?

olive vessel
#

No, I think it just has to be a Command, sent from any script derived from NetworkBehaviour

#

I'm sure there are plenty of tutorials online for this though

green tide
#

Well there a plenty of tutorials for spawning objects from the player object, but now for spawning objects from non player objects

#

The problem is with authority. Non player objects cant for some reason spawn new objetcs

olive vessel
#

But commands can be set to ignore authority

green tide
#

Except for when u use ignore authority

#

Yes. Ive read some things about avoiding to use this

muted yarrow
#

Hi there ! Is there anyone that knows UNet well ? I have a problem.

olive vessel
#

UNet is deprecated

#

You should really use a different solution, like Mirror, MLAPI or Photon PUN

muted yarrow
#

I know that. Its a simple project that I want to learn something new.

olive vessel
#

Don't learn UNet, it is deprecated

#

What's the point of learning something, that is no longer supported or used?

muted yarrow
#

You right. But it's a project that is about to finish. And i faced with a problem.

olive vessel
#

So we've gone from simple learning, to finished product

#

What's the issue then?

muted yarrow
#

Thanks for answering and help here. I tried a few communities but no one answered.

#

Let me show the code.

#

The problem is this. I copied that :

How can i implement my item customization for a LAN game.
I made a local one that player can choose some items like weapons in main menu and when enters to local scene, my warrior reads item index from PlayerPrefs class and Instantiates it and sets parent. For example sets sword for a hand. It works right in local scenes but in UNet story is different.

You know getting item index is something that should execute in client. Client should tell the server hey it's index of my item and server lnstantiate and assign that in all other clients.

How can i implement these process ? I used Command and ClientRpc but didn't work.

olive vessel
#

You've not even started adding in multiplayer functionality to those classes?

muted yarrow
#

These are what I did for local one and It's work well. But in UNet story is complex

#

Let me show UNetItemAssign class.

olive vessel
#

Honestly, I am gonna give you one piece of advice, stop using UNet immediately and switch to a newer networking solution, you don't look that far into this certainly not to the point where it's painful to switch

#

You are shooting yourself in both feet, by using old deprecated systems, that nobody wants to support

#

Mirror, MLAPI and Photon PUN are all great systems, with great communities of people willing to help

muted yarrow
#

You right. But its just a university project and I should submit it in a few days. That's my fault that I choose a deprecated system. But anyway I have to finish that.

#

Every time a player joins to server it should tell index of items and other players send him their itmeIndexes.

merry nymph
#

Hi
So, I'm using MLAPI now cuz UNet has been deprecated...
Everything is fine except that there is no NetworkDiscovery component for mlapi, and according to the docs: "MLAPI does not provide Network Discovery. The UNet Network Discovery is a standalone component that can be used with any networking solution. You can use the UNet Network Discovery to discover a broadcasting MLAPI host and then connect to it with MLAPI."
But so ye I'm confused now how will I use UNet's NetworkDiscovery with mlapi if UNet is deprecated?

#

Ping me when you answer ^

wet skiff
covert plank
#

only difference is im using telepathy atm, but neither that nor KCP have been working

frozen hull
#

re
how can i make a player counter using photon?
Like : 2/8 players in game

weak plinth
#

question with pun RPCs serious issue... I have buffered RPCs they work on any player if they leave room then rejoin... but if the master client leaves then joins again they don't work... anyone who faced such a problem ?

regal delta
#

I believe that's how mirror and MLAPI work. If the host is no longer hosting your RPC's are gonna have a bad time

#

You'd have to renegotiate who is the "server" and who are the clients...which sounds tricky to do at runtime

covert plank
#

how would i check the ping of a player? ( using mirror )

olive vessel
covert plank
dawn patrol
#

does any here use phton that could help me?

#

photon

#

.pun

old nova
#

what should l change or add in this script so all client see when a player shoot a bullet photon pun

dawn patrol
#

it MUST be PhotonNetwork.Instantiate

#

not instaniate

#

@old nova

old nova
dawn patrol
#

o.o

#

that took long

old nova
#

lol

dawn patrol
#

can anybody please help me i have an object im setting a inactive and it is working on one screen but not the other

#

using photon pun2

spring crane
#

Unless you have some specific use case, it seems like a hack to replay bunch of stuff just to replicate dumb state

#

I believe there are conditions in which some buffered RPCs are cleared, so I would look into that. Documentation likely has something about this.

#

Which based on your issue, likely are related to the owner or target of the RPC not being around anymore

spring crane
#

I don't think PUN tracks active state by default

weak plinth
frozen hull
#

hi

#

how can i make a player counter using photon?

short island
#

pun or realtime @frozen hull

#

anyone notice the unity web requests are kind of slow

#

my azure api is a bit slow from unity

#

:/

#

if you want to know how many players there are in a session that is builtin to photon

frozen hull
#

What '' function'' i need to use?

#

Or wich, idk i'm bad in English

short island
#

for PUN?

#

to see how many players are in a room

frozen hull
#

Yep

short island
#

PhotonNetwork.CurrentRoom.Players

#

more specifically PhotonNetwork.CurrentRoom.Players.Count

#

for the player count

frozen hull
#

So i can use something like countValue.text = PhotonNetwork.CurrentRoom.Players.Count

#

;

short island
#

yeah but

#

PhotonNetwork.CurrentRoom.Players.Count.ToString();

frozen hull
#

Thx

modern drift
#

im using mirror and for some reason when i try getting a script on the player prefab it says its null(when it is there). could it be that i ask it too early? or any other reason?

old nova
#

how can l show the panel and destroy gameobject too

olive vessel
#

Doesn't appear to be a networking question, but that should do it, unless the Destroy needs to go after the SetActive

modern drift
#

put the panel.SetActive(true); before Destroy(gameobject)

#

when u destroy the gameobject u also destroy the script that is on it

#

so the next line doesnt go off

weak plinth
#

does anyone know what Can not Instantiate before the client joined/created a room. State: PeerCreated means?

#

and for some reason when i start the game, my player doesnt spawn

#

not sure if ^ is the reason for that or not.

old nova
#

how get l change this scrip so the deathpanel show before my player with the script on this destroy it

vital hawk
spring crane
spring crane
weak plinth
spring crane
#

The client has several states. You can't create networked objects in certain states. To fix it, you just don't spawn objects until the state is a valid one

#

PUN provides several callbacks you can listen to for state changes and there are properties you can check to make sure you don't spawn objects in a bad state

weak plinth
spring crane
#

There are properties like InRoom and NetworkClientState

latent gull
#

guys, can someone tell me, why it might not work? Or i do something wrong?

        {
           // string sty = SceneManager.GetActiveScene().name;
            string try2 = Application.dataPath + "/Records/" + "Dungeon2" + ".txt";
            using (var uwr = new UnityWebRequest("link", UnityWebRequest.kHttpVerbPUT))
            {
                uwr.uploadHandler = new UploadHandlerFile(try2);
                yield return uwr.SendWebRequest();
                if (uwr.result != UnityWebRequest.Result.Success)
                    Debug.LogError(uwr.error);
                else
                {
                    Debug.Log("upload");
                }
            }
        } ```
i have no errors, but no result and it works good 
``` public IEnumerator DL()
        {

            //Download
            string sty = SceneManager.GetActiveScene().name;
            string try2 = sty.ToLower();
            UnityWebRequest dlreq = new UnityWebRequest("link" + try2 + ".txt");
            dlreq.downloadHandler = new DownloadHandlerFile(Application.dataPath + "\\Records\\" + sty + ".txt");
            UnityWebRequestAsyncOperation op = dlreq.SendWebRequest();
            while (!op.isDone)
            {
                //here you can see download progress
                Debug.Log(dlreq.downloadedBytes / 1000 + "KB");
                yield return null;
            }
            if (dlreq.isNetworkError || dlreq.isHttpError)
            {
                Debug.Log(dlreq.error);
            }
            else
            {
                Debug.Log("download success");
            }
            dlreq.Dispose();
            yield return null;
        }```
ornate zinc
latent gull
#

I'm stupid, sorry ๐Ÿ˜„ i had Debug.LogError(uwr.error), but i thought that i have Debug.Log(uwr.error), so error "HTTP/1.1 403 Forbidden" maybe problems with permissions, right?

weak plinth
#
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using Photon.Pun;

namespace Com.LuxStudios.FieldsOfBlood
{
    public class Manager : MonoBehaviour
    {
        public string player_prefab;
        public Transform spawn_point;

        private void Start()
        {
            Spawn();
        }

        public void Spawn ()
        {
            PhotonNetwork.Instantiate(player_prefab, spawn_point.position, spawn_point.rotation);
        }
    }
}```
spring crane
#

Well it looks like you are spawning without any regard to the network state, so if that script is present in a scene where the network state can be offline, you would get that error

weak plinth
#

i dont think its offline.

spring crane
#

Or not in a room. PUN will tell you, as you have discovered ๐Ÿ˜„

#

Again, use the properties and callbacks to explicitly wait for the state to become valid

weak plinth
#

wdym "not in a room"

spring crane
#

In a PUN room

Can not Instantiate before the client joined/created a room.

weak plinth
#

hold on

#

it works now

#

and i dont think i did anything

#

but now i cant sprint, and move my camera up and down

cobalt python
#

hi guys! i am using photon. How can i make player rb to act more sharper for others? When players jumps and descends it slows down before reaching the ground. It looks too smooth. transform view is disabled.

ornate zinc
cobalt python
# ornate zinc how do you control the velocity/gravity of this player?
void Movement()
        {        
            movementX = Input.GetAxis("Horizontal");
            movementZ = Input.GetAxis("Vertical");
            moveVec = Vector3.ClampMagnitude(orientation.right * movementX + orientation.forward * movementZ, 1.0f) * speed;
            moveVec += Vector3.up * rb.velocity.y;                                         
            rb.velocity = moveVec;
        }

        void Jump()
        {
            if (inventoryMode)
                return;

            isOnGround = Physics.CheckSphere(groundCheck.position, groundDistance, groundMask);

            if (isOnGround && velocity.y < 0)
            {
                velocity.y = -2f;
            }

            if (Input.GetKeyDown(KeyCode.Space) && isOnGround)
            {
                rb.AddForce(Vector3.up * jumpForce, ForceMode.Impulse);
                isOnGround = false;
            }
        }
ornate zinc
ornate zinc
# cobalt python just physics based!

And where do you set the movement for the network player? long time ago I was using photon, but what is actually handling the transform for others

cobalt python
#

i changed now rigodbodysync script to default photon rigidbody view component and it looks better. Strange

#

i dont know the difference

ornate zinc
#

Maybe its just some settings you can set there

cobalt python
#

thanks

ornate zinc
weak plinth
#

So Iโ€™m trying to make multiplayer right now using mirror and fizzysteamworks. Iโ€™ve successfully made a host button, and the ability to join from a separate pc and separate steam account, when I join it shows both players, but the movement is not transferring between client and host

olive vessel
#

Does the player prefab have a NetworkIdentity and NetworkTransform?

novel topaz
#

Hello, i am using mirror and i have a lobby/room system to allow my player to join a room and ready-up then the game launch, but i can't manage to allow player to join the game once it's "launched".
I try to see through the differents mirror scripts the differents method called when the player successfully join the room and when he can't join the game.
The main difference between both case is that OnServerConnect isn't called on player trying to join the game once it's launched (maybe this is the reason why they can't join the game), whereas OnClientConnect is successfuly called.
Can somebody help me ?

split zenith
#

Anyway to make it into a single method without using mutliples RPCs? (pretty new to photon)

old nova
#

how can l change this script so it update when player leave game

delicate gyro
# old nova how can l change this script so it update when player leave game

inherit from MonoBehaviourPunCallbacks

then override the OnPlayerLeftRoom method

example:

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using Photon.Pun;
using Photon.Realtime;

public class Name : MonoBehaviourPunCallbacks
{
    // ...
    public override void OnPlayerLeftRoom(Player player)
    {
        // put code here
        UpdatePlayersList();
    }
    // ...
}
old nova
#

l'm try to update text when player die

delicate gyro
old nova
#

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using TMPro;
using Photon.Pun;

[RequireComponent(typeof(TextMeshProUGUI))]
public class PlayersConnectedUI : MonoBehaviour
{
TextMeshProUGUI connectedText;

private void Start()
{
    connectedText = GetComponent<TextMeshProUGUI>();
}

private void Update()
{
    connectedText.text = $"{PhotonNetwork.CurrentRoom.PlayerCount}/{PhotonNetwork.CurrentRoom.MaxPlayers} Players Connected";
}

}

delicate gyro
# old nova like this

i guess that can work (but youll be updating the text every update UnityChanAfraid )

here's a way but it only updates when a player joins or leaves

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using TMPro;
using Photon.Pun;
using Photon.Realtime; // for 'Player'

// inherit from M-B-PunCallbacks
[RequireComponent(typeof(TextMeshProUGUI))]
public class PlayersConnectedUI : MonoBehaviourPunCallbacks
{
    TextMeshProUGUI connectedText;

    private void Start()
    {
        connectedText = GetComponent<TextMeshProUGUI>();
    }

    private void UpdateText()
    {
        connectedText.text = $"{PhotonNetwork.CurrentRoom.PlayerCount}/{PhotonNetwork.CurrentRoom.MaxPlayers} Players Connected";
    }

    // these are some callbacks that M-B-PunCallbacks give
    // see docs on photon website
    public override void OnPlayerLeftRoom(Player player)
    {
        UpdateText();
    }

    public override void OnPlayerEnteredRoom(Player player)
    {
        UpdateText();
    }

    public override void OnJoinedRoom()
    {
        // prob good idea to update when join room
        UpdateText();
    }
}
old nova
#

thank

old nova
delicate gyro
old nova
delicate gyro
old nova
#

l only want it to update text when player leave

delicate gyro
#

itโ€™s errorinf because the method doesnโ€™t exist

#

Update is a unity-reserved method (from M-B-) that is called every update frame so you shouldnโ€™t really use itโ€ฆ

old nova
delicate gyro
#

private void UpdateText()
{
// keep the code inside of it
}

old nova
# delicate gyro private void UpdateText() { // keep the code inside of it }

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using TMPro;
using Photon.Pun;
using Photon.Realtime;

public class PlayersConnectedUI : MonoBehaviourPunCallbacks
{
TextMeshProUGUI connectedText;

private void Start()
{
    connectedText = GetComponent<TextMeshProUGUI>();
}

private void Update()
{
    connectedText.text = $"{PhotonNetwork.CurrentRoom.PlayerCount}/{PhotonNetwork.CurrentRoom.MaxPlayers} Players Connected";
}

public override void OnPlayerLeftRoom(Player player)
{
    โ€œUpdateTextโ€();
}

private void UpdateText()
{
    // keep the code inside of it
}

}

delicate gyro
#

i meant to change the name of the method

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using TMPro;
using Photon.Pun;
using Photon.Realtime;


public class PlayersConnectedUI : MonoBehaviourPunCallbacks
{
    TextMeshProUGUI connectedText;

    private void Start()
    {
        connectedText = GetComponent<TextMeshProUGUI>();
    }

    // v here v 'Update' is a Unity-reserved method name
    private void UpdateText()
    {
        connectedText.text = $"{PhotonNetwork.CurrentRoom.PlayerCount}/{PhotonNetwork.CurrentRoom.MaxPlayers} Players Connected";
    }

    public override void OnPlayerLeftRoom(Player player)
    {
        UpdateText();
    }
}
old nova
#

what a script that l can add in my game which leave room and join the same/create a room

#

photon pun

olive vessel
#

Plenty of Photon PUN tutorials online, nobody will give you script

patent oasis
#

Not for anything complicated, just a small game I want to make for my friends and myself.

old nova
#

why l'm l get this problem

prime geyser
#

anyone know why when i join a server with clients they just clip into the floor and bounce?

#
using UnityEngine;
using MLAPI;
public class PlayerMovement : NetworkBehaviour
{
    public CharacterController ChrCtrl;

    //Run lines every frame
    void Update()
    {
        if(IsLocalPlayer)
        {
            MoveCharacter();
        }
    }
    //Move the player
    void MoveCharacter()
    {
        Vector3 move = new Vector3(Input.GetAxis("Horizontal"), 0, Input.GetAxis("Vertical"));
        move = Vector3.ClampMagnitude(move, 1f);
        ChrCtrl.SimpleMove(move * 5f);
    }
}```
#

heres the code im using

#

oh wait im dumb

#

just realized im clamping it at zero

#

wait a minute

#

its clamped to the correct positio

#

but on the server its still bouncing

#

on the client its just fine

#

now im really confused

#

nvm its working

sick plank
#

I have a StateController that gets attached to each one of my NPC's that controls everything from moving to the actions they're taking.

There is no hot join.

Is there an easy way to convert that to be supported via Mirror? I was hoping I could just put a [Server] tag on the update where UpdateState gets called. But Im not really sure currently. Any help would be great.

scenic fulcrum
#

this might be a pretty noobish question but ... im trying to build an authorian server by hand right now and i am struggeling. Should i build it timer based or tick based and how do i properly send the movement inputs of the clients towards the server when they are not running on the same tick speed?

#

or if anyone has a good tutorial on that topic i would love to read or watch it

high night
#

@scenic fulcrum
State(t) + Inputs(t) -> State(t+1)

#

Tick based

#

Hmm, clients running different tickrates?

#

Hmm, that'd make the movement prediction weird no?

scenic fulcrum
# high night <@!159838872107220995> State(t) + Inputs(t) -> State(t+1)

but how do i catch them? I mean, lets say my game runs at 120 fps, so 120 updates per second and my server has a tickrate of 10. I cant just snapshot my inputs 10 times a second and send them over and sending a list of all inputs and their length seems complicated and way to big for a package that gets send often

high night
#

If you wanna do snapshot interpolation, client should constantly keep two ticks

#

last two

#

And interpolate

#

Client will be viewing the past though

scenic fulcrum
#

can you explain this to me ?

high night
#

you have a client time right?

#

and you have the tick times

#

you interpolate between last two ticks using client time as interval

scenic fulcrum
#

on the client? yeah. I dont have them on the server as of now because it simply ticks 10 times a second without any timing stuff (as of now) im still new to network development

high night
#

or something based on client time, if you client time is in the future

scenic fulcrum
#

hrm im having a hard tme to understand what you mean, can you write me a simple theoretical example ? :/

#

also thanks for taking the time to help me!

high night
#

you should have the server time as a float as serverTick * constantDeltaTime

scenic fulcrum
#

oh yeah i have a constant TIME_PER_TICK

#

whic his currently 100ms

#

in a simple world, what if my client has pressed 50ms of "move right" and 50ms of no input ... how would i transfer it over to the server?

high night
#

I am kinda busy now, we can voice chat later

scenic fulcrum
#

sure, would love that!

ivory coral
#

Hi, I have a little problem. I'm using Playfab's leaderboard system to hold my data. When I load up the game and click on a button, it Debug.Logs all the scores in the console. The first time is fine, but when I select the button again, it Debug.Logs twice. And then a third time if I press the button again and so on. How can I make it so that it only Debug.Logs once? When I hit the button I run the Login function that let's me login into the sever then run GetLeaderBoard(); right afterwards. It gets the information just fine, but it duplicates it and I have no idea why

hearty dock
#

Photon Fusion question - for anyone who happens to know:
According to the docs:

Fusion automatically calls OnInput() on all SimulationBehaviours implementing the INetworkRunnerCallbacks interface and over which the client has Input Authority - hence the name.
And yet I have a script:cs public class PlayerMover : SimulationBehaviour, INetworkRunnerCallbacks
That has input authority. I know it does because this prints true in both Spawned() and in FixedUpdateNetwork():

print($"We have input authority? " + Object.HasInputAuthority);```
And yet OnInput is not running on the script.
What else should I be checking?
#

So maybe the docs are just a lie right now, but I got it working with:

if (Object.HasInputAuthority)
{
    Runner.AddCallbacks(this);          
}``` in `Spawned()`
vague mantle
#

should i use dots Unity for rts game online 2d guys ?

tardy coral
#

Hi, I have this issue with networking,
I run my game at Unity and at builded game, I have a ball and 2 players, the ball acts differently on the Unity(Host) and the builded game(Client), it doesn't act same. What can that be about? Network Transform or I dont really know help me ๐Ÿ™‚

jovial cave
#

Hey guys, I'm using a springjoint on my client to move my player. For an unknown reason, i'm only able to shoot a player attached 1 of 5 times. It feels like if the collision wasn't fixed at the same spot than my playermodel.

I'm using Mirror btw.

Any idea ?

stray scroll
stray scroll
ivory coral
#

I see

red bough
#

Is this outdated for unity 2019.1.10f?

verbal lodge
red bough
verbal lodge
#

Which one? MLAPI? HLAPI?

red bough
#

Any of it

#

Im stepping into networking and I wanted to check which things I should read first

verbal lodge
limber holly
#

I have to create a target window ( UI element with the target name + health ) for multiplayer rpg game. Someone can advise me a way to do this, because I stuck for this morning.

pine lynx
verbal lodge
#

Yes

pine lynx
#

I would think so. Thanks for the script Luke! ๐Ÿ˜„
I was having errors replicating a simple rigidbody player, but I solved it. Somehow I left the "Interpolation time" on the NetworkRigidbody at zero, which in turn caused it to not work properly at all.
Simple error, but hard to spot when I'm completely new to networking in games.

#

Just one of those times where asking for help cause you to find the error yourself

verbal lodge
#

Oh I see, it's 0 by default if you add it to a GameObject right?

pine lynx
#

Yes!

#

Maybe there should be a tooltip or warning about a value of zero, but that may be just be me being a bit of a noob

verbal lodge
#

Yeah and I think we can give that a better default value, I'll take a look tomorrow.

pine lynx
#

Thanks! Now that it's working I'm really impressed with how simple it is to set up ๐Ÿ™‚
Good work

wind hinge
#

i have a question about OnPlayerLeftRoom and OnPlayerEnteredRoom in Photon

#

this is my text for "OnPlayerEnteredRoom" :

public override void OnPlayerEnteredRoom(Player newPlayer)
{
base.OnPlayerEnteredRoom(newPlayer);
Instantiate(logText, logImage.transform);
logText.text = newPlayer.NickName + " has joined the room.";
logText.color = Color.green;
}

and this is the text for "OnPlayerLeftRoom" :

public override void OnPlayerLeftRoom(Player otherPlayer)
{
base.OnPlayerLeftRoom(otherPlayer);
Instantiate(logText, logImage.transform);
logText.text = otherPlayer.NickName + " has left the room.";
logText.color = Color.red;

}
#

but for some reason "LogText" .text = "Nickname has left the room" when the person joined and vice versa. idk why and if you do pls tell me! ๐Ÿ™‚

languid yarrow
#

Hello. I use Mirror networking in my game. The game is first person, but I don't know what to do to hide the player model for the owner. If anyone knows the solution, please help. Regards.

olive vessel
languid yarrow
olive vessel
#

With isLocalPlayer? The local bit gives it away

languid yarrow
#

I will use this method. If it doesn't work, I'll keep looking for the answer.

chilly grail
#

Hey something out of topic but im just curious, can you see what functions the driver for your network card exports and use said functions from within a driver of yours?

minor escarp
#

I have a question my photon view transform doesnt work can someone send a working code

#

Does the script where its movin the chracter have to be in update to use the photon view

hollow mountain
#

Which service would be better for backend? I have to have a simple google sign in and a leaderboard.. firebase or playfab?

patent fog
#

I guess playfab will go a little further for you out of the box. I'd expect a little more setup and coding on the firebase side.

outer osprey
#

Hi all. what is the best way to make p2p game?
so player1 will create room(and host it on his device), others can see that room in lobby, and join him
thanks

minor escarp
#

And tutorial from blackthornprod

minor escarp
#

I cant make progress

olive vessel
jolly wadi
olive vessel
#

No

jolly wadi
#

Ok

jolly wadi
olive vessel
#

If they want help, they should provide errors and full scripts in paste sites so that people can assist them

jolly wadi
#

Oh well

#

Just ignore him

#

If you got a problem

minor escarp
jolly wadi
#

Report him

olive vessel
#

Feel free to report me, but the moderators would say the exact same things as me, you're now going wildly off topic

jolly wadi
#

No report techy 12 I mean

minor escarp
#

pls stop the wels cow

minor escarp
#

why

#

i am new

olive vessel
#

There's no need to report him, Techy just needs to provide details about the problems they're having, that's all

minor escarp
#

can you help me

jolly wadi
#

No I mean if he got a problem donโ€™t have to blatantly take it out on him it is very disrespectful he has barely been in this chat

jolly wadi
#

And so arenโ€™t you

olive vessel
# minor escarp can you help me

I don't have experience with Photon, but if you provide details about the issues you're facing, others can help you faster

jolly wadi
#

I donโ€™t see you helping him

minor escarp
#

pls thanks for the tips that it doesnt work pls stop

jolly wadi
olive vessel
#

<@&502884371011731486> Can this Shadow guy be dealt with, just incoherent rambling at this point

#

All I said, was that to get help you must ask questions and provide details of the issue, that's all

jolly wadi
#

Whatever a community moderator does I donโ€™t care if you canโ€™t help donโ€™t talk,simple!

olive vessel
#

How can I help, when the guy literally said "help me" and gave no details of errors? You can't help someone with a problem that they haven't asked about.

minor escarp
jolly wadi
#

He did provide detail

#

He said his photon transform views donโ€™t work

olive vessel
#

Really? He said 4 fucking lines, not one single error was in those lines

#

Not one single line of code was provided

minor escarp
jolly wadi
#

He doesnโ€™t need to provide codes for transform views

olive vessel
jolly wadi
#

What code is there to provide

olive vessel
#

God knows, but they could have said more than "it doesn't work help me"

jolly wadi
#

Ok idc imma drop it

minor escarp
#

or go do it in a dm or something

#

i am going to try by giving better info

spring crane
#

Yes

#

Where is all this aggression coming from? I'm just trying to tell you these things and leaving it at that.

minor escarp
#

ok so my photon view component isnt working i dont know what the problem is it isnt showing on another device if i move my character with photon view component on it its in a resources folder the prefab so that isnt the problem its also shows when join the player can you see but you cant see it moving.

#

this is my movement code:

spring crane
#

@minor escarp Check #854851968446365696 for how to send long code snippets. Photon View component doesn't sync position in itself, other components like the transform view component do additional syncing.

jolly wadi
#

Donโ€™t use photon view for 2d games

#

I make your own script and use synchronisation states

#

You can check out photon documentations on that

minor escarp
#

yeah i forgot in my message transform

inland sand
#

Hi, I'm using mirror with eos and I dunno why but when using online and offline scene slot, it spams null reference error how do I fix?

minor escarp
#

do you have more info

inland sand
# minor escarp do you have more info

When using epic online service with unity and using mirror's example scene "tanks", on default settings it works fine but when I add offline scene to offline scene slot and game scene on online scene slot in network manager it spams me null reference error as soon as the game scene loads

#

And then my unity freezes

minor escarp
#

do you have any other errors

#

otherwise check if everything is fine with the component

#

so no blank spaces

#

i dont know much about mirror

#

photon how to make your own script and use synchronisation states

gleaming prawn
#

Perhaps you should watch a few youtube tutorials

#

Because nobody will answer questions that are as generic as these.

#

But in short, you can implement OnSerializeView (I believe this is the name of the callback) so you can either write (from the client that owns the object) or read data.

wind hinge
#

does anybody know how to sync text in photon unity across all players

#

i tried syncing it with photonMessageInfo and sync the names in the text but it didnt work(it didnt sync(It showed different names on different clients))

split zenith
#

Hey everyone, basically i can't figure out how interest groups work in photon and can't seem to make this work

#

The "OtherTeamLights" RPC is supposed to disable the lights of this player only on players that are part of the other interest group (ie on the other team)

burnt frigate
#

hi , i need help with unity photon pun , its a bit of a special case so it will be easier if you can dm me, this problem is about having a UI showing a int into a text for each player but idk why only 1 player reiceive the data and the int so for him it show (1 / 5) for other it show (0 / 5) :/

torpid flax
#

has anyone used OVLcloud before for VPS?

covert plank
#

What networking solution should i use if im looking to make a rouge like mmo type game (I need something thats well documented)

#

also does anyone know if unity's own multiplayer solution is ready to be used?

modern drift
covert plank
modern drift
#

yeah probably. if you are just starting out make a simple multiplayer game in it for now but don't go all in. if you are a beginner and not familiar with learning through documentation i might wait till theres more info out there so you wont get discouraged. multiplayer especially is hard. i started learning mirror 2 weeks ago and am having some trouble lol.

take what im saying with a grain of salt tho im not the most experienced

covert plank
covert plank
#

I'll definitely make a new project to test it out though

modern drift
#

gl

covert plank
#

thanks

#

its hard learning all these new things at once but im enjoying it

modern drift
#

but yeah mirrors documentation is kinda meh sometimes like sometimes in the code summarys it says somehing else then what it says on the website lol

modern drift
covert plank
#

im about 4 months on unity now

#

although only recently started putting every hour i have into it

modern drift
#

cool

#

im on and off for like 2 years i think?

covert plank
#

cool cool

modern drift
#

but i feel more confident the more i do things

covert plank
#

yeah I'm definitely feeling that

modern drift
#

rn trying to do architecture for card effects in a hearthstone clone im making in mirror and its not easy :D

covert plank
modern drift
#

never too late to try

#

if you like rougelikes i would recommend slay the spire

covert plank
#

I'll look into it, thanks for the recommendation

modern drift
#

np