#archived-networking

1 messages ยท Page 68 of 1

wicked marlin
#

Yea, that's weird. I'd have to look into that.

empty yew
#

I could swap the data onto an object without photonview as well

rancid anvil
#

Any idea to make a leaderboard

weak plinth
gloomy meteor
#

hey

#

my photon player animations wont sync

frozen canopy
#

Hello there, a 250 mbps bandwidth Dedicated Server will be able to resist a multiplayer that is sending to the servrer and to the client for example 250 vector3?

#

every time (the players)

#

This one, will be able to resist more than 250 players that sends their position to the server all the time?

gloomy meteor
#

heyy

#

i can see my animations over locally when testing but other players cannot see it over the network

jade glacier
#

You are using photonAnimatorView? @gloomy meteor

gloomy meteor
#

yes

#

@jade glacier animations work perfectly fine locally

#

But why would they not sync/play over the network?

jade glacier
#

You dragged that sync into the PhitonView list of onserializeviews?

gloomy meteor
#

Any idea?

#

Hmm.. whats that?

jade glacier
#

You did the tutorials?

gloomy meteor
#

Yes

#

Oh i did it

#

You meant this?

jade glacier
#

Yup, that

#

Disabling your controller code on unowned objects?

gloomy meteor
#

yes

#

but still the animations wont sync

jade glacier
#

Dunno then, sorry. You have a bug somewhere.

gloomy meteor
#

but how do they work fine locally?

#

when i see them through the scene view

jade glacier
#

Because that's not networked

gloomy meteor
#

yea but i have the photon animator view right?

#

should it just not sync automatically?

jade glacier
#

Yes, unless something else you have going on is fighting it

gloomy meteor
#

nope nothing

jade glacier
#

Code isn't magical, you have a bug or conflict somewhere.

frozen canopy
#

how many people uses Unity Multiplayer intead of Photon? in %?

gloomy meteor
#

but how come if i have a bug it works locally? i am not syncing any additional data over the network

jade glacier
#

You're gonna have to debug every step of the process and see where things are breaking.

gloomy meteor
#

oh

gloomy meteor
#

bro do i need to call rpc to call the animation booleans?

stray scroll
#

@frozen canopy I think you can count on your hands by how many people are using Unity Multiplayer if you're referring to DOTS NetCode

frozen canopy
#

I refer to Unity Default multiplayer system that has NetworkManager NetworkManagerHUD, NetworkIdentity, etc...

jade glacier
#

Maybe @gloomy meteor For the SNS extensions I use passthrough methods for triggers, play, etc.

nocturne jungle
#

Looking for suggestions on networking tools for database interactions, in-game log in, adding items, retrieving data, etc.

#

Is Photon fully scalable?

empty yew
#

I've swapped to PhotonNetwork.LoadLevel but my Lobby script will still not show up in DontDestroyOnLoad

#

I think I fixed it. I figured all photon ids would automatically be unique, because that actually makes sense. I tested it by changing the id by code in start, but it didn't like that. I changed it in inspector and it seems ok

frozen canopy
#

@nocturne jungle build an easy web-service

#

with php

nocturne jungle
#

I have the back end written in PHP, and a front end CMS to populate the SQL DB. Just wondering if there is an integration tool specific to Unity that the community prefers.

amber trench
#

@nocturne jungle if you don't have multi-user interactions, you should think really hard if you need it at all

lapis temple
#

@nocturne jungle what is your server like ? i made two graphs may help you

vivid owl
#

if anyone has used it

#

I'm considering migrating some of our microservices

frozen canopy
#

How to make that the Player is moved by the Server in Photon PUN?

spring crane
#

@frozen canopy By the relay or the masterclient?

frozen canopy
#

I don tknow what you mean

#

by the server xd

#

by the photonnetwork

weak plinth
#

Since PUN game rooms are hosted by a master client (initially the player who made the room unless it has been transferred during runtime) and the game servers itself are hosted by Photon and therefore are not accessible, you are not technically able to implement authoritative movement logic.

#

However, you could make the master client act as a "server", though that can sometimes be pretty complicated.

#

For example, sending local inputs (wasd, spacebar etc...) to the master client who then calculates the next positions & rotations etc... and then proceeds to send it back to the client who then applies those.

#

Though that can be quite unstable in most cases, for example when the master client disconnects / has his game frozen or crashed.

silent zinc
#

Python Asyncio or c# multithreading?

#

for a multiplayer game Unity based

thick fossil
#

Anyone know how to bypass the "please enable JavaScript in your browser" using Unity Web Request?

tropic adder
#

If I build my online Photon Game and play it, my Player cant join the Room!

jade glacier
#

"can't" ?

#

@frozen canopy There is no server in PUN2, unless you start writing server plugins for the relay

#

The relay IS the server, but it is a server that has no knowledge of your game, it is just there to manage connections and traffic between clients.

#

The Master Client isn't a server, it is just a client that has been handed the baton saying it is the master - which is just to give you the ability to call one of the clients the final word, and indicates which client will own scene objects.

#

Server authority movement with PUN shouldn't be tried without server plugins. You don't want to treat your master client as if its a server, the latencies involved will be very disappointing.

tropic adder
#

"can't" ?
@jade glacier Yes

jade glacier
#

I mean that doesn't say enough for anyone to help you

tropic adder
#

There its work

jade glacier
#

Dunno

jade glacier
#

You are giving nearly no info about your code. So all I can say is you have a bug.

#

Have you done the pun getting started tutorial?

tropic adder
#

Yeah

#

From InfoGamer?

#

Here @jade glacier

#
using UnityEngine;
using Photon.Pun;
using Photon.Realtime;
using UnityEngine.UI;


public class NetworkManager: MonoBehaviourPunCallbacks
{
    public GameObject[] spawnPoints;
    
    void Start()
    {
        PhotonNetwork.ConnectUsingSettings();
    }

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

    public override void OnJoinedLobby()
    {
        PhotonNetwork.JoinOrCreateRoom("Room", new RoomOptions {MaxPlayers=2}, TypedLobby.Default);
    }

    public override void OnJoinedRoom()
    {
        int randomNumber = Random.Range(0, 1);
        Vector3 spawnPoint = spawnPoints[randomNumber].GetComponent<Transform>().position;
        PhotonNetwork.Instantiate("Player", spawnPoint, Quaternion.identity);
    }
}```
#

And PlayerNetworking:

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

public class PlayerNetworking : MonoBehaviour
{
    public MonoBehaviour[] scriptsToIgnore;

    private PhotonView photonView;
    // Start is called before the first frame update
    void Start()
    {
        photonView = GetComponent<PhotonView>();
        if (!photonView.IsMine)
        {
            foreach (var script in scriptsToIgnore)
            {
                script.enabled = false;
            }
        }
    }

    // Update is called once per frame
    void Update()
    {
        
    }
}
#

That are the relavent Scripts

vivid owl
#

what server library would you recc for turn-based games?

jade glacier
#

I would explore cloud services first

#

If you can avoid hosting any metal boxes of your own that is best in most cases.

frank leaf
#

im just starting out with adding multiplayer to my fps, can sb please reccomend me a good tutorial/other means of learning how to make shooter pvp?

jade glacier
#

Bolt is going to probably be your best first thing to try for a proper competitive fps

frank leaf
#

what is bolt @jade glacier

#

bolt is for visual scripting

#

what does it have to do with making a game multiplayer

amber trench
#

@vivid owl the reason i recommended magic onion is that you'll be able to author server-side compatible code from inside the unity editor

#

which in my experience in turn based games

#

is very valuable

#

you will waste far less time on marshalling/remoting problems in disguise

#

when it comes to stuff like login, just use AspNetCore's identity framework

#

it will cover 99% of your usecase

#

but as soon as you need to author something like a matchmaker, you will waste so much time not having it in-editor

#

otherwise few people are trying stuff that is self hosted

#

it just sin't the way normals do things

vivid owl
#

I see

#

I do need a matchmaker as well

#

and I already have a login server written in Go

#

which I'll be using to generate JWT tokens

amber trench
#

be straight with me though

#

is that the only thing you have written

vivid owl
#

no

amber trench
#

what else

#

we're going to just go through

#

and think, is this valuable

#

because a game doesn't need JWT tokens

vivid owl
#

authentication is something that's needed

amber trench
#

you'll just be stuck adapting to stuff that doesn't really matter

#

the world has a lot of auth systems

vivid owl
#

there's a login server, a server that handles CRUD operations and fetching static data, and battle server written up already

amber trench
#

nobody makes video games with go, so you will find zero packages for it

#

okay, describe battle server to me

#

like for an existing web app game?

vivid owl
#

turn-based battle

#

and not web

#

targetting desktop/mobile

amber trench
#

okay, battle server, what is the client

#

for the battle server

#

other go code?

#

it's an embedded battle server

vivid owl
#

no, Unity

#

currently, battle server is also written in go, using websockets

amber trench
#

so you have an existing, TCP based networked battle server

#

oh

vivid owl
#

yes

amber trench
#

it sounds like this thing is written

vivid owl
#

I'm thinking of replacing it with MagicOnion though

amber trench
#

and exists

#

i see

vivid owl
#

mostly because I need to find polyglot developers to assist with the project, if we're using both

#

and that could be difficult

amber trench
#

you will find zero yeah

#

but

#

i think if you have a thing that exists

#

it's a different story

#

if this game works, today, and it exists

vivid owl
#

it's also currently only 2k lines

#

the battle server code, I mean

amber trench
#

it took me about an afternoon to get aspnetcore running from the unity editor

#

with kestrel

#

and another afternoon to get SignalR to work

vivid owl
#

you can run ASP.NET Core from unity editor?

amber trench
#

however, i never tested it with il2cpp, where it will almost certianly not work

#

yes

vivid owl
#

this changes everything

#

and yes, we're using IL2CPP

#

does MagicOnion work well with IL2CPP?

#

anyways, I'm also currently using Kubernetes to handle all my services, and thinking of adding Agones controller to the stack

amber trench
#

i'm a lot more likely to believe

#

that neucc authored something that works on il2cpp

vivid owl
#

I checked the docs, it seems like it does work on IL2CPP

#

although you need some additional tooling

#

anyways, how do you run ASP.NET Core from editor?

#

from what I know, the editor itself uses Mono, even when the project type is IL2CPP

#

are there guides on how to do this

amber trench
#

here i got something special for you

#

it's not really a framework

#

just open sample scene and hit run

#

make sure you have two game views open

#

one set to display 1, another set to display 2

vivid owl
#

thanks

amber trench
#

you can click on the networking game object, and if your computer network is correctly set up, you can seamlessly change between no transport and networked signalr transport

#

also observe that it is simulating two game clients

#

in one editor

#

with the appropriate point of view

#

without cloning your project

#

and it is clearly turn based

#

because it is 1D chess

vivid owl
#

does MagicOnion depend on ASP.NET Core/SignalR?

amber trench
#

and it just uses kestrel

vivid owl
#

I see

amber trench
#

i'm not sure

#

this is the best i could do for the ideal multiplayer game ergonomics

#

that is totally self hosted

vivid owl
#

nice

amber trench
#

but is hosted (i.e., multiple game instances per single process)

#

but you can see i just use the aspnetcore DLLs

#

these's a lot of magic here though

vivid owl
#

nice

#

also, how do I do this, in case I have many microservices?

amber trench
#

well

#

the thing is

#

developer ergonomics and microservices

#

don't go well together

vivid owl
#

I think mocking/dependency injecting parts of the microservices could work

amber trench
#

the whole point is to avoid

vivid owl
#

for current dev cycles, I've been spinning up minikube pods

amber trench
#

"and then you visit this website""

#

i just think that

#

if you get a unity developer

#

and you utter the words docker or kubernetes or whatever

#

they'll just space out

#

they'll be like, this isn't for me

#

the whole point is that they hit the play button, and things work

vivid owl
#

true

#

TBF, we have multiple developers on our team

#

there's a clear separation of backend and frontend in our teams

#

I don't think there's any fullstack devs, whatsoever

#

I just ask one of the members on the client team to run stuff for me if I want to test things

#

which, I will say, is ergonomically horrible

prime nexus
#

Is there a way to use Terrain collisions with NetCode/UnityPhysics/DOTS?

stiff ridge
#

You should do that locally, not via the net.

delicate kindle
#

How can i have a like a input filed that the player can enter their username and then later use it in-game? (MULTI PLAYER GAME)

#

@ me if you know to do that

jovial rapids
#

@amber trench there are dotween pro assets in your repository, is that allowed?

thick fossil
#

Anyone know how to bypass the "Enable javascript" warning u get when web requesting to an url that requires it?

frozen canopy
#

Hello, will changing the values of:
PhotonNetwork.sendRate
PhotonNetwork.serializedSendRate

#

improve my player syncronization?

prime nexus
#

You should do that locally, not via the net.
@stiff ridge should be done in the server which syncs the simulation to the clients, but adding the terrain in Shared Data (Convert to Client Server Entity) seems incompatible with the old terrains

gleaming prawn
#

@frozen canopy yes, and at the same time it will incur in a lot more bandwidth use. You need to understand what is being sent, etc.

#

There are other ways to improve "player synchronization"

#

Depends on what are the issues you have now.

frozen canopy
#

Yep, i saw a way by sending the player position to other clients via RPC

#

is that viable?

#

or it will use A HUGE amount of bandwidth?

#

Can i send a video so you can see the exact probleem that i have?

gleaming prawn
#

is that viable?
No... RPCs are not to be used in high frequency, they are worse

#

Can i send a video so you can see the exact probleem that i have?
No... As I discussed with you already, these are a bit more complex than you think. It's good you are willing to learn.

#

I suggest you take a step back and try to study resources about multiplayer game development.

#

It's difficult for me to "answer". You need to be able to understand a few basics so you can ask the "right" questions.

frozen canopy
#

The game and m ultiplayer itself is working perfectly

#

Thats just 1 little mini-bug

#

that i dont know how to fix

gleaming prawn
#

There are many good developers in this channel, but most of them will only answer these "right" questions.

#

Thats just 1 little mini-bug
It's probably not a bug

frozen canopy
#

See, this is the problem

#

look at the head

gleaming prawn
#

Yes, this is jitter

#

Network sends are jittery, this is the nature of the internet. You can do two things:

  • interpolate OR
  • extrapolate
jade glacier
#

SNS would likely solve that for you, but it is in Beta so the docs are light

gleaming prawn
#

I think the photon view even has an option for you (for interpolation, for extrapolation you'd need to include player input and process that yourself)

#

But emotitron's SNS gives you much much better control of this

jade glacier
#

its all on the tick, so that kind of jitter would go away, in exchange for some other hurdles

#

Be sure with whatever you are using, that you are simulating in Fixed, not in Update

#

misusing those timing segments results in jitter with networking as well

frozen canopy
#

where can i cahnge the interpolation and extrapolation? i don't remember @gleaming prawn

gleaming prawn
#

Not sure if it's available as a checkbox... I mentioned the basic concepts you can use...

#

They are easy to implement (if not there already, I think the transform view does interpolate)

#

SNS implements these AFAIK.

#

I do not work directly with PUN, which is what you are using.

frozen canopy
#

OMG just saw that i miss-removed the component PhotonTransformView fromt the player...

#

can it be the issue?

#

@gleaming prawn

#

Nop, with PhotonTransformView looks even more jitter

gleaming prawn
#

If you have a manual implementation, you do not need the transform view

#

These are mutually exclusive.

#

Transform view moves the transform for you... if you had something working without it, it's because you wrote some code for it...

#

If you follow the basic tutorials you should have no jitter

frozen canopy
#

Now its working pretty fine

#

just reduced the speed of the player

#

just a little bit

high night
#

Can i perhaps see a character controller code that you might have written for a tick based networking system in your games? (doesn't matter what type as long as it's tick based)

I am looking for an example that every tick responds to multiple frames

I'd like to see how inputs and subtick info is handled in detail

frozen canopy
#

How can i see the Player number that are inside a Specific room from another Scene?

#

(using photon)

ocean ledge
#

Besides photon and unity's build in networking what other networking solutions exist today(usable with unity) for a VR shooter multiplayer?

jade glacier
#

Most will be, but you will have to do a lot of the wiring up of things yourself

#

I'm right now doing work for Exit looking into expanding some tools for Oculus - but that is pretty early.

ocean ledge
#

I don't mind wiring up

#

the important factor is versatility, scalability and readability

jade glacier
#

Not sure any of those words go with Oculus ๐Ÿ™‚

whole granite
#

Hey guys
Quick question.
I have a Unity.Transport Driver and it is getting one ScheduleUpdate at each fixed update frame.
And I would like to minimize the latency, is it a good idea to schedule a second update somewhere at the end of the frame in LateUpdate (with some flag ofc., so it will not update if there was not any FixedUpdate at the current frame)? Then I can wait for the job to get finished at the next fixed update frame.

#

And the whole idea is to minime the latency as I said, aaaaand it should "force" the queued packets to be sent... right?

frozen canopy
#
    void OnJoinedLobby()
    {

        for (int i = 0; i < roomNameList.Count; i++)
        {
            roomOptions.MaxPlayers = 2;
            roomOptions.IsOpen = true;
            PhotonNetwork.CreateRoom(roomNameList[i], roomOptions, null);
        }

        PhotonNetwork.JoinRoom("Room8");
        
    }```

This doesn't create 10 rooms in the Photon Lobby, it asks me to first call the "OnJoinedLobby" or be the master client or something, how can i fix
gleaming prawn
#

you can only create/or-BE in ONE room from a client

#

You cannot create multiple rooms from one client.

#

When you create a room, you also JOIN it automatically.. You cannot create a second.

#

Have no idea what you are trying to achieve, but this is not how you use photon.

frozen canopy
#

Yep i know now no problem

#

I want to be able to make several rooms with 2 or 3 players of capacity @gleaming prawn

#

and that a player can choose what room to connect

#

and see how many players there are in each room from th elobby

#

and choose a room

gray pond
weak lava
#

Any advice on Nagle's Algorithmus? I know tcp is not rly common in games netcode, but if tcp ,is it used with Nagle's ?

spring crane
#

My understanding is that you should be disabling it. Mirror networking has dealt with that recently with their TCP transport

gray pond
#

Yep, we disable it by default, although that was put in over a year ago (Jan 2019).

spring crane
#

Yea meant recently as in the history of networking solutions ๐Ÿ˜›

weak lava
#

Alright thanks :)

weak plinth
#

What happens if I use a MonoBehaviour instead of a NetworkBehaviour? What's the difference?

silent zinc
#

How many digits should have an integer Client ID?

ocean ledge
#

@gray pond is mirror good enough for real time fps?

tropic adder
#
using UnityEngine;
using Photon.Pun;
using Photon.Realtime;
using UnityEngine.UI;


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

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

    public override void OnJoinedLobby()
    {
        PhotonNetwork.JoinOrCreateRoom("Room", new RoomOptions {MaxPlayers=2}, TypedLobby.Default);
    }

    public override void OnJoinedRoom()
    {
        PhotonNetwork.Instantiate("Player", new Vector3(140, 190, 0), Quaternion.identity);
    }
}
```How I can let the other player join on the cords 600, 190, 0?
jade glacier
#

Get a player count in OnJoinedRoom and use that to pick the spawn point? That won't account though for players leaving and others arriving after that. You probably would want the master client to manage spawn points.

tropic adder
#

Ok. I did it. But now I have this Error:

#

Assets\Photon\PhotonUnityNetworking\Resources\NetworkManager.cs(30,22): error CS1501: No overload for method 'CheckSphere' takes 1 arguments

#
using UnityEngine;
using Photon.Pun;
using Photon.Realtime;
using UnityEngine.UI;


public class NetworkManager: MonoBehaviourPunCallbacks
{
    public GameObject[] spawnPoints;

    void Start()
    {
        PhotonNetwork.ConnectUsingSettings();
    }

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

    public override void OnJoinedLobby()
    {
        PhotonNetwork.JoinOrCreateRoom("Room", new RoomOptions {MaxPlayers=2}, TypedLobby.Default);
    }

    public override void OnJoinedRoom()
    {
        Vector3 spawnPoint1 = spawnPoints[0].GetComponent<Transform>().position;
        Vector3 spawnPoint2 = spawnPoints[1].GetComponent<Transform>().position;
        if (!Physics.CheckSphere(spawnPoints[0]))
        {
            PhotonNetwork.Instantiate("Player", spawnPoint1, Quaternion.identity);
        }
        else
        {
            PhotonNetwork.Instantiate("Player", spawnPoint2, Quaternion.identity);
        }
    }
}```
#

@jade glacier

jade glacier
#

So fix that

tropic adder
#

I dont know, what this it?!

#

Please help me.

jade glacier
#

Reading basic debug errors is a bit off topic for networking. That is more a question for the regular Unity coding channels.

tropic adder
#

Ok.

#

But what is "overload"?

jade glacier
#

I would strongly recommend not trying networking until your have a firm grasp of Unity and. C#...

#

Or this is going to be very slow and painful.

tropic adder
#

Ok. ๐Ÿ˜ข

gray pond
#

@gray pond is mirror good enough for real time fps?
@ocean ledge Sure. You'll have to implement Lockstep or rewind yourself, of course, but the networking is up to the task.

ocean ledge
#

cool! thank you ๐Ÿ™‚

weak plinth
#

@real mountain

#

You asked about photon, right?

real mountain
#

Yeah, thansk

weak plinth
#

So

#

What you want to know?

real mountain
#

Actually I'm making an fps multiplayer game, battle royal and I am using photon. The problem here is how can I use it to make a working lobby and the match....

weak plinth
#

A question

real mountain
#

Also, is there a way I can get a players name?

weak plinth
#

Isn't too laggy for FPS?

#

Photon

#

As I know, yes.

real mountain
#

Idk, I haven't configured the game for now, I'm still on the lobby

weak plinth
#

Well

#

I'll help you anyways

#

So

real mountain
#

Ok, thanks

weak plinth
#

You want to make a lobby where players can connect, right?

#

With a maximum of players

real mountain
#

Yeah, actually 4

#

4 would be the maximum per lobby,

weak plinth
#

Oh ok

#

So

#

You must create a new scene and give it the name Launcher.unity

#

Then

#

As I did for my game, create a script

#

Named Launcher

#

(After all I am just saying what I saw in a tutorial time ago, you can find these things online)

#

Done?

real mountain
#

Ok...

#

Actually, do you know how to instantiate the player object and get his/ her name?

weak plinth
#

So,

#

Here

#

Is easier to show than to explain

real mountain
#

Thanks

weak plinth
#

๐Ÿ‘

silent zinc
#

Help pls

#

I'm able to send data, but the SendData function doesn't return (it doesn't Set the sendDone event...)

#

The Debug.Log("MMM"); doesn't show

#

And Unity Freezes when it finish sending the data to the server.

silent zinc
#

I noticed that the callback SendCallback doesn't even run...

wise creek
#

Which multiplayer solution is best?

weak plinth
#

Depends.

#

What game are you trying to make?

#

@wise creek

#

In fact there's a detailed post about what you should do during the UNet depreciation

dire river
#

Hi, I would like to load certificates from android device so I can send a secure https request to my backend server.
But given code returns empty certificates collection in Unity. In plain windows c# console app it works.
Do you know why?

using (var store = new X509Store(StoreName.Root, StoreLocation.CurrentUser))
{
store.Open(OpenFlags.ReadOnly);
return store.Certificates;
}

weak plinth
wise creek
#

Thanks. @weak plinth

weak plinth
#

I know it's not my place to say but 99% ||(in my case 3% why god)|| of problems you encounter, no matter about scripting or others, Googling gets you the answer.

cosmic roost
#

I know! There are so many questions where the answer is a simple unitydocs or forum or stackoverflow that can be easily searched. That being said, I understand it's hard for newcomers and they might not know of those resources.

jade glacier
#

I do wish people would use these channels for help finding the right directions to look. Way too many people coming here looking to have their hand held every step of the way and have other's debug and write their code for them.

#

Once some directions are suggested, people really should head back to google with that new knowledge.

cosmic roost
#

I agree

delicate kindle
#

@tropic adder i see that you are using Photon, how do you spawn your players? for ex when i spawn them some players spawn on the same spawn position, how can i fix that?

jade glacier
#

I think he is the wrong person to ask, since he is trying to sort that out himself.

tawny edge
#

He's sorting rotation not translation.

delicate kindle
#

yep

#

idk how to fix that, i have 2 spawn points and sometimes the player 01 will spawn in player 02 spawn point

jade glacier
#

You can have the Master be responsible for giving out spawn points, and have players stay in limbo until they get one from the Master. Or you can have them do an overlapsphere test or such and choose their own spawnpoint based on crowding...

tawny edge
#

By spawning do you mean Instantiating?

jade glacier
#

there is no native way, since there is no server.

cosmic roost
#

I don't know about Photon, but brackeys has a FPS tutorial and in there somewhere he talks about managing spawns and spawn positions... the short answer is you instantiate a player at a random vector3 that has been clamped.

delicate kindle
#

ye @tawny edge

jade glacier
#

So it does fall on the dev to decide how to deal with where players spawn

#

UNET FPS stuff will be different, because there you code the server, and the server does the spawning

delicate kindle
#

i tried using a bool is occupied

#

but the bool is not syncing

jade glacier
#

in PUN2 the relay is the server, and it has no game simulation - it is just a relay.

delicate kindle
#

with every client

tawny edge
#

You could have an area right like two points x and z and choose a range.

jade glacier
#

You first have to decide what is the spawn position authority.... the player, or the master client

#

Or you can make a Photon Server plugin, but that is getting a bit more advanced than any new dev probably wants to get when starting

tawny edge
#

Was isOccupied static? Cause I think it has to be if many different script want to access it with the same result

cosmic roost
jade glacier
#

You can also round robin spawn points based on PlayerId

#

using modulus

cosmic roost
#

just instead of respawn, make it spawn

jade glacier
#

You can't apply UNET principles for spawning to PUN2

#

UNET relies on the server to do the spawning

delicate kindle
#

does UNET has matchmaking? like PUN2?

jade glacier
#

Not in the same way

delicate kindle
#

i was thinking about just pressing ready or what ever and you are in a matchamaking

jade glacier
#

PUN2 is a completely relay based system, so it acts more like P2P in most ways

#

If you just want your players to not all spawn on top of one another, I would make X number of spawn points, index them, and use the PlayerId to pick which one to use.

#

You can revisit that later with something more complicated, but that will get you basic distribution at startup

delicate kindle
#

can you send a tutorial or sm cuz i am new to networking

cosmic roost
#

yes, that's what he explains in his video, he just goes into more detail about how to do it... but the basic concept works with Photon. Just use the spawning idea from there (called round robin) and network it using Photon

delicate kindle
#

What video?

#

@cosmic roost

cosmic roost
#

just make sure you're using the concept, not the networking part because Photon will be different than Unet

delicate kindle
#

ye i know that

jade glacier
#

With that example the server is just going to keep track of the last used index.... for PUN2 you have to do int spawnToUse = ActorId % numberOfSpawnPoints

tropic adder
#

Sorry. I wasnt online @delicate kindle.

weak plinth
#

I was thinking on maybe implementing some multiplayer but have no experience. I was looking at this tutorial -> https://www.youtube.com/watch?v=MOLlHw0yn5g and it seems I can just use my current game and convert it? Does this mean unity has a built in networking system or? I would appreciate some more information. Thank you

In this tutorial I show you guys how to move around on a multiplayer server! I also show you how to make sure the cameras are in the right position, rotation, and if they are viewing the right player!

Project Files : https://www.dropbox.com/s/2ugnhn6z91upaql/Multiplayer Rac...

โ–ถ Play video
#

Do I need to download anything?

#

I also looked at other tutorial and they seem to use the same network manager stuff

fleet juniper
#

Which multiplayer system/asset do you want to use?

#

UNet (deprecated)
Photon/PUN2?
Mirror?

#

and yes you need to download something

weak plinth
#

umm I'm not entirely sure

#

which one was the one the person used in the tutorial?

fleet juniper
#

UNet

weak plinth
#

oh that's sad

fleet juniper
#

I don't recommend to use UNet

weak plinth
#

because of the deprecated

#

yup

#

does photon work the same?

#

cause in the video it seemed pretty fast to implment 7 min

fleet juniper
#

Photon / PUN2 works differently, but it should be easier to use.

weak plinth
#

ok thanks

fleet juniper
#

no problem

fierce niche
#

I'm trying to set up a GameSparks Leader Board and I'm not sure how I can create an event / running total. I see that a new field for my leader board requires a running total, but the running total also requires an event. But I cant find where to create an event (I think its meant to be under configurator but I dont see it). Ty in advance!

fierce niche
stray scroll
#

@fierce niche Is this anything related to unity?

fierce niche
#

Ty for inquiring. It is a service amazon provides to game devs including unity. But I got reply elsewhere, again Ty anyway

vivid owl
#

@amber trench are there any good tutorials for magiconion?

#

or the API docs

stoic marsh
#

Hi guys! Im doing a server and i need your help to make a live clock for different countrys! Can you help me pls? Im working so hard and i need your help! thank you!! (and sorry for my english but it isnt my native laguage) cheers!

sacred jewel
#

@fierce niche do you have permission to access it?

#

it should show under configure > events

#

go to game overview and edit button make sure it's enabled under features and integrations

weak plinth
#

I installed photon bolt but can't seem to find bolt in the windows button

#

please help

#

oh nevermind sorry

weak lava
#

HI i just check out Telepathy and read this Async Sockets: perform great in regular C# projects, but poorly when used in Unity. Could any one provide some more Informations? I know Telepathy and Mirror perfome great but this Telepathy uses two threads per connection. It can make heavy use of multi core processors. seems suspicious to me.

graceful zephyr
#

@weak lava So, async sockets do perform badly in Unity.

#

It has to do with the ancient implementation of them being used in Unity (from its Mono version), it's just not good.

#

But claiming that 'Telepathy' makes great use of multi core CPUs because it uses two threads per connection is just... well, eh... that's not how you do that.

#

If you are looking for something with works like old UNET, then yeah use Mirror. Otherwise look elsewhere.

weak lava
#

Are there any Benchmark test out there ? I currently working on my own Framework and im using async. Its not only for unity but it also should work in Unity. So i have to decide, i guess ?

graceful zephyr
#

Completely depends on what you're trying to do, TCP vs UDP, How many connections you want to handle, packet rates, etc.

vale rover
#

I've used Mirror and Telepathy in one project. It worked pretty good but it wasn't subjected to heavy traffic.

stray scroll
weak lava
#

atm im using TCP but maybe switch later to UDP, it should handle up to 20-30 ccu and a packet rate of about 30-40/sec.

graceful zephyr
#

@weak lava for 20-30 CCU it doesnt matter what you use

#

async will be fine

#

i'd probably just go with one thread and a Socket.Select poller for that low count

#

no point in mixing async or multiple threads into it

undone sigil
#

@graceful zephyr afaik, when i looked at decompiled code, in unity .Select allocates an array on every call

graceful zephyr
#

it'll still be fine ยฏ_(ใƒ„)_/ยฏ

#

async API allocates IAsyncResult etc.

weak lava
#

alright thanks @graceful zephyr

weak plinth
#

and if I need it

gleaming prawn
#

This is a tutorial project, of course you do not need these.

#

Try to read the docs and follow the tutorials

weak plinth
#

I read this in one of the photon forums No, you can press tab be default to disable it or turn it off in the Bolt settings. You can also implement BoltLog.IWriter and have it work as you want. I'm not sure what he means tho @gleaming prawn could you clarify?

whole granite
#

You can turn it off in the bolt settings.

weak plinth
#

where would that be

#

I don't see anything related to console

mint acorn
weak plinth
#

thank you

silent zinc
#

Hi, i'm trying to build a network system for my multiplayer game, but i'm struggling in making the recv system...i've tried to follow the code from microsoft docs, in order to create an async socket recv operation...But with no success...when i use microsoft's code, my unity game freeze when trying to send/recv data...

#

Can anyone give me a snippet of code? To understand how should i implement the recv system with async sockets?

#

In Microsoft's docs, they say i have to create a StateObject class that holds the data/socket for the async calls

#
public class StateObject {  
    // Client socket.  
    public Socket workSocket = null;  
    // Size of receive buffer.  
    public const int BufferSize = 256;  
    // Receive buffer.  
    public byte[] buffer = new byte[BufferSize];  
    // Received data string.  
    public StringBuilder sb = new StringBuilder();  
}  ```
#

The Recv Method should look like this...```cs
private static void Receive(Socket client) {
try {
// Create the state object.
StateObject state = new StateObject();
state.workSocket = client;

    // Begin receiving the data from the remote device.  
    client.BeginReceive( state.buffer, 0, StateObject.BufferSize, 0,  
        new AsyncCallback(ReceiveCallback), state);  
} catch (Exception e) {  
    Console.WriteLine(e.ToString());  
}  

} ```

#

And the Recv Callback should be this...cs private static void ReceiveCallback( IAsyncResult ar ) { try { // Retrieve the state object and the client socket // from the asynchronous state object. StateObject state = (StateObject) ar.AsyncState; Socket client = state.workSocket; // Read data from the remote device. int bytesRead = client.EndReceive(ar); if (bytesRead > 0) { // There might be more data, so store the data received so far. state.sb.Append(Encoding.ASCII.GetString(state.buffer,0,bytesRead)); // Get the rest of the data. client.BeginReceive(state.buffer,0,StateObject.BufferSize,0, new AsyncCallback(ReceiveCallback), state); } else { // All the data has arrived; put it in response. if (state.sb.Length > 1) { response = state.sb.ToString(); } // Signal that all bytes have been received. receiveDone.Set(); } } catch (Exception e) { Console.WriteLine(e.ToString()); } }

#

The problem is that receiveDone.WaitOne() makes the unity game freeze for some reason...

#

when trying to call Recv() in a Callback inside a Unity Component...

#

with StartCoroutine()

#

So...is there a better way of implementing this?

silent zinc
#

DM me if u have the time to help me ๐Ÿ™‚

oblique charm
#

yo guys im doin a simple setplayername

#

but i've got a problem

#

im doin a continue button

#

and an input field, if i write something on the input field the button needs to become interactable

delicate kindle
silent zinc
#

i really lost the hope...

stray scroll
#

@silent zinc Can't really see where receiveDone.WaitOne() is called, but blind guess would be that you're locking thread waiting for receive from socket.

#

Coroutines runs on mainthread afaik, so you're locking unity by that point.

silent zinc
#

@stray scroll I tried without blocking with WaitOne(), but i can't recv the response...

wicked turtle
#

Hey everyone, I'm using SteamVR 2.5 & PUN 2.0 and I'm wondering if anyone ever encountered an issue where the master (and probably anyone else) opening the SteamVR dashboard would delay the sending of events or network view updates to other clients? I've already disabled SteamVR_Settings.instance.pauseGameWhenDashboardVisible So I'm not sure what's happening
Update: Seems the behaviour is inconsistent as in it's not doing it anymore... weird

stray scroll
#

@silent zinc so what is happening with this code you posted? Does it freeze? Where does it freeze?

silent zinc
#

@stray scroll It doesn't freeze, not anymore, since i deleted the WaitOne() and Set() parts...The problem is that it is inconsistent in the results... i mean, it doesn't receive messages from the server. The server is not the problem though...

silent zinc
#

I managed to solve that problem, now i recieve the response, but another problem occurred, since i don't know much about tcp...my response seems to have multiple messages in it... I'm struggling in sending a large base64 string over tcp...

silent zinc
#

I'm so confused, in python i could just use the asyncio library pre-built classes, to make an asynchronous client...in c# i have to make the protocol by myself...

#

How can i ensure that the entire message gets received correctly?

silent zinc
#

I don't know how, but somehow, now everything works fine...

slim ridge
#

@silent zinc I use a BufferedStream for my tcp. A way to ensure the whole message is received is to begin your messages with an integer representing the number of bytes in your message

#

Then it's a simple process: read the message size, read that many bytes, next message

sacred canopy
#

I don't really know what chat to put this in but I really want to make a game but have know idea how to do, I don't know any code or anything. I have really good ideas for a game but I need somebody to help me, its a 3d battle royal, if you are interested, DM me.

jade glacier
#

If you haven't made a single player Unity game... do that first. Don't even consider making a multiplayer game as your first Unity project.

#

@sacred canopy

sacred canopy
#

ok

jade glacier
#

Networking games is literally THE hardest and least supported part of Unity.

#

Starting there will make you want to quit game dev.

slim ridge
#

lol been there before

sacred canopy
#

i dont know where to start

jade glacier
#

Just the Unity tutorials on their site is a good first step

sacred canopy
#

ok

jade glacier
#

You need to first get familiar with the UI and coding in C# with monobehaviours

sacred canopy
#

i dont know what any of that means lmao

slim ridge
#

how comprehensive is your design?

jade glacier
#

Use the regular dev channels for that, there is lots of support there and in like the GDL discord

#

@sacred canopy That's the point, you have to do the tutorials to even know where to start

sacred canopy
#

ok i will look up one

frozen canopy
#

Hey please, this is a Unity issue, i cannot make WWW requests in the WebGL build, it just freezes the game

#

I tried enabling CORS in htaccess config

#

but nop

slim ridge
#

cors issue usually indicate a problem with your server configuration

#

are you using https?

#

The server to which you are making the requests is probably not set up to accept them from whatever network you're on.

frozen canopy
#

The server that i make the request to is HTTP, not https @slim ridge

slim ridge
#

I never used WebGL sorry

#

i can only guess that it makes a blocking network request. If there's some way to set a timeout that might help

#

You might also try your request in another application like Postman then resolve the differences between that and webgl

frozen canopy
#

Trying another way instaead of WWW @slim ridge

#

with HttpWebRequest

#

and HttpWebResponse

#

classes from c#

#

Didn't work

#

This seems a fucking joke..

slim ridge
#

nah man, web requests aren't easy

frozen canopy
#

Tried with "UnityWebRequest" class, with "WWW" class, and now with "HttpWebRequest" class, and all 3 doesnt work

#

in a webgl build

#

But no unity helpers help on it

#

thats what kills me

#

that is not my fault, its unities fault

slim ridge
#

it's probably not a unity problem them, i'd guess the problem is with the information in the request itsself or the server

frozen canopy
#

the server is fine

#

i can make requests to it

#

with a Android build

#

or Windows build

#

workd pefectly, but with WebGL buil fail

slim ridge
#

great, then you have a place to start. Get a log of that successful android request and then compare it to the unsuccessful ones you're making with webgl

frozen canopy
#

All those 3 classes works perfecty on all builds except on webgl xd

#

now this error displayed @slim ridge

slim ridge
#

what does browser javascript console say?

frozen canopy
#

same

#

as i sent you

slim ridge
#

need to see the whole stacktrace

frozen canopy
#

its just the same repeated

slim ridge
#

probably a unity bug then. What option do you use for "Enable Exceptions" ?

weak plinth
#

is it possible to spawn a Netcode ghost inside of a job or would I need to do that on the main thread?

stray scroll
#

@weak plinth Structural changes has to be done on the main thread, but can be recorded in a commandBuffer in a job. So what you would do is to create a commandBuffer from one of the sync points (i.e BeginSimulationSystemGroup, EndSimulation--, etc), feed it into your job, Instanciate your ghost there, where you can also do Set/Add components, which will then be played at next Sync point (when the group you created the commandBuffer from's Update is run).

weak plinth
#

@stray scroll thank you for that info. my current method is using the ECB to instantiate a prefab with a ghost authoring component on it that is then converted. however, I'm getting this error: InvalidOperationException: Could not find snapshot data Cube (1)SnapshotData, did you generate the ghost code?

do I need to pass the ghost collection in to the job somehow and reference it with a ghostId?

stray scroll
#

@weak plinth are you saying you're instantiating a gameObject and converting it?

weak plinth
stray scroll
#

Yeah ok, so only bad phrasing. So this is how I get the prefab to spawn

                var prefabs = GetSingleton<GhostPrefabCollectionComponent>();
                var serverPrefabs = EntityManager.GetBuffer<GhostPrefabBuffer>(prefabs.serverPrefabs);
                m_crewPrefab = serverPrefabs[SpaceCraftGhostSerializerCollection.FindGhostType<CrewSnapshotData>()].Value;
#

To make it work you'll need to ofc have the prefab and updated it's list and generated the code

#

And also have the prefabs in the scene to create the Singleton entity, if you haven't click Update ghost list to get it in the list, then generate collection code.

weak plinth
#

alright I'll see if I can get that to work. thanks again

weak plinth
stray scroll
#

@weak plinth Can't really tell by the picture, but generally try check the quick guide if there's something fundamentally you've missed. But for debugging, go the entity debugger; check in both client and server world if the entity exist (not only the prefab but the actually spawned entity). There is no default rendering in server world, to render in client world with entities you'll need Hybrid Rendering package.

cedar cloak
#

trying to make Photon load a scene with "PhotonNetwork.LoadLevel(1);" but it wont load

#

the scene has the right index and there are no errors shown

whole granite
#

Is there any info/tips about latency optimization for Unity.Networking.Transport?

#

For example, I just do not want to wait whole frame and for the next one to start just to send my packets queued at the beginning.
Ideally I would like to know, if there is any possbility to split receive/send jobs.

civic stream
#

Is someone able to assist me real quick with some Photon PUN?

#

So I have two RPC methods that I want to sync across all clients, however only one of the methods work

#

here is the code I use

#

so my test() method is called on my player.cs script (attached to the player), but syncID() is not

#

either I'm not sending the RPC from my gamemaster.cs, or for some reason my player.cs doesn't accept the call

stray scroll
#

@whole granite I don't really see the problem? Just put your send in send jobs?

#

Won't NetworkDriver.Concurrent.EndSend(DataStreamWriter) send it right away?

whole granite
#

I don't think so. As it has internal send queue.

#

Oh, actually it will.

#

Thanks @stray scroll

stray scroll
#

It calls return NativeBindings.network_sendmsg(*(long*)userData, &iov, 1, ref *(network_address*)addr.data, ref errorcode);

#

yeah

whole granite
#

Yeah, just saw that too ๐Ÿ˜‰

#

I've been mistaken by the pendingSend

cedar cloak
#

any help?

stray scroll
#

@cedar cloak calling it on master client?

cedar cloak
#

yes

cedar cloak
#

I'm really getting mad cause the script its only few lines and should work correctly

slim ridge
#

Don't get mad, get data ๐Ÿ˜„

civic stream
#

can anyone help with my problem?

jade glacier
#

You have tried a basic test scene outside of your project to make sure you are using the method correctly? @cedar cloak

#

I don't use RPCs so that part of PUN I can't speak to... but abusing buffered RPCs is asking for trouble - I know that.

#

@civic stream

slim ridge
#

yeah and u call it in Update() that's probably overflowing some buffer somewhere

civic stream
#

ah

#

I see

#

so should I just use all instead of bufferedall?

#

or can I clear the buffer?

slim ridge
#

also you access the photonview three different ways xD

jade glacier
#

Clearing the buffer would defeat the point of the buffer no?

civic stream
#

yeah ik

#

I tried different ways

#

to make it work

#

figured that might be the issue

jade glacier
#

People typically use buffer to make late joiners initialize correctly no?

civic stream
#

yeah

slim ridge
#

there must be something to tell you that an RPC has completed successfully or errored?

civic stream
#

yeah

jade glacier
#

its not meant to be spammed, and the docs I think warn against that.

civic stream
#

I put a print() to signify if the RPC method has been called

jade glacier
#

Just RPC normally

civic stream
#

wdym

jade glacier
#

not buffered

#

Or better, RaiseEvent on your own and take full control

civic stream
#

kk

#

tks guys

cedar cloak
#

You have tried a basic test scene outside of your project to make sure you are using the method correctly? @cedar cloak
@jade glacier yes

#

the 2 scenes are basically empty

jade glacier
#

dunno then. If its included in the BuildScene list, it should be getting indexed. They all have unique names i assume?

cedar cloak
#

sure

slim ridge
#

can you load the scene programmatically without photon?

cedar cloak
#

can you load the scene programmatically without photon?
@slim ridge you mean with loadscene?

slim ridge
#

yeah

cedar cloak
#

tried SceneManager.LoadScene(1) and doesnt work too .-.

slim ridge
#

ok then you know it's probably an issue with the scene and not photon

jade glacier
#

Then its not a networking issue, its just an issue

cedar cloak
#

right

jade glacier
#

Best to hit up the regular unity help channels for that kind of thing

#

your are restricting yourself on help quite a bit by trying to sort that here

civic stream
#

@cedar cloak try loadscene(0)

#

or just multiple values

cedar cloak
#

seems like some issue regarding the method

#

in some way OnJoinedRoom() is not working

jade glacier
#

You need to show code if you want any feedback on where you are going wrong

#

Otherwise all we can do is nod our heads in agreement that yes you have a bug

cedar cloak
#

here's the code

#

please save my life

#

The script is attached to and Empity Obj in the supposed Main Menu (0) and should take to the Game (1)

slim ridge
#

I never used photon so i dont think i can help

#

If you can't even load the scene with scenemanager perhaps you should ask in general-code

jade glacier
#

either use hatebin.com or paste your code here using ```cs //yourcode ```

cedar cloak
#

its not about the scene loading itself

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

public class Launcher : MonoBehaviourPunCallbacks
{

    public void Awake()
    {
        PhotonNetwork.AutomaticallySyncScene = true;
        Connect();  
    }

    public override void OnConnectedToMaster()
    {
        Debug.Log("CONNECTED");

        Join();

        base.OnConnectedToMaster();
    }

    public override void OnJoinedRoom()
    {
        StartGame();

        base.OnJoinedRoom();
    }

    public override void OnJoinRoomFailed(short returnCode, string message)
    {
        Create();

        base.OnJoinRoomFailed(returnCode, message);
    }

    public void Connect()
    {
        Debug.Log("Trying to connect...");

        PhotonNetwork.GameVersion = "0.0.0";

        PhotonNetwork.ConnectUsingSettings();
    }

    public void Join()
    {
        PhotonNetwork.JoinRandomRoom();
    }

    public void Create()
    {
        PhotonNetwork.CreateRoom("");
    }

    public void StartGame()
    {
        if(PhotonNetwork.CurrentRoom.PlayerCount == 1)
        {
            PhotonNetwork.LoadLevel(1);
        }
    }
}
#

The problem is the OnJoinRoom whitch doest work, tried to put a DebugLog in there and doesnt appear

slim ridge
#

oh okay

#

JoinRandomRoom fails if no room is available

#

perhaps you need to use JoinOrCreateRoom

#

oh i see

#

your joinraondomroom fails so you make a room but dont try to join it

#

PhotonNetwork.CreateRoom("") -> PhotonNetwork.JoinOrCreateRoom("") ?

burnt axle
#

@cedar cloak Have you tried the built in demo setup tool to see if that works?

cedar cloak
#

PhotonNetwork.CreateRoom("") -> PhotonNetwork.JoinOrCreateRoom("") ?
@slim ridge doesnt work ๐Ÿ˜

#

@burnt axle wym witht that?

burnt axle
#

I think a room needs a name, not an empty string

cedar cloak
#

for now it should work

#

I've tried to follow a tutorial and the code is identical

burnt axle
#

Try to use a debugger in your texteditor/IDE

cedar cloak
#

no errors

burnt axle
#

Follow the trail and see what happens

cedar cloak
#

what else should I check?

burnt axle
#

Set a breakpoint on the join statements, and see what photon does internally

#

You can also check to see if the pun framework is working in general by trying out a demo: unity editor > window > photon unity networking > Configure demos (built setup)

jade glacier
#

if(PhotonNetwork.CurrentRoom.PlayerCount == 1) what is that check trying to achieve?

#

Second player to join a room is going to fail that test

cedar cloak
#

yes because first player should create the level while the others should sync to that already created one

#

so I put a DebugLog on every functiona and it just does the Connect() and Join()

slim ridge
#

no OnJoinRoomFailed ?

cedar cloak
#

no

#

it just run these 2, like doest get the joined ones

slim ridge
#

lol this why i dont use photon

burnt axle
#

You are trying to create a room right? And it fails while not calling OnCreatedRoom, OnJoinedRoom or OnCreateRoomFailed?

cedar cloak
#

so basically it start by searching a room, if the players doesnt find any available it should create a new one

jade glacier
#

You probably mean to have the MasterClient do the scene changes, rather than just playercount == 1. Likely means the same but you are opening yourself for edge cases.

burnt axle
#

I just tested a simple script for the same purposes you are trying to do, and it works fine here

cedar cloak
#

I just tested a simple script for the same purposes you are trying to do, and it works fine here
@burnt axle using basically same as mine?

burnt axle
#

But you should really test the Demo first, just to make sure that Photon works in general

#

@cedar cloak Yes, just a basic script for connecting and creating/joining rooms

jade glacier
#

What @burnt axle said for all networking, avoid complexity or too many moving parts at once.

#

My life as an asset dev is people dumbing 20 assets into a project, and copy pasting a bunch of stuff from 5 different tutorials and then emailing me with "Your asset isn't working"

#

Networking is fragile as F

cedar cloak
#

i just followed 1 long tutorial to reach this point, I know that copy bunch of random asset will surelly fuck up the project

jade glacier
#

The tutorials are to show you workflow btw... NOT for cutting and pasting code from

#

I wouldn't start with a tutorial (they are all questionable at best anyway)

cedar cloak
#

and its super strange and its working on him and not on me, other people in comments got this issue too but noone replied yet

slim ridge
#

yeah i recommend using .Net and writing your own protocol.

jade glacier
#

Do the tutorial... then throw it out.

#

If its in the comments to that tutorial, then sounds like the tutorial has a bug

cedar cloak
#

Do the tutorial... then throw it out.
@jade glacier I will but i would to complete it first to understand what happend, for now I knew 100% about the not Photon related code, but since the networking part is new for me at the beginnig would prefer to follow instruction of someone whos already into it

jade glacier
#

Which again, is why I would not copy pasta from any networking tutorials. They are notoriously TERRIBLE

#

you are stuck ON the tutorial?

#

as in the tutorial isn't working as advertized?

#

If you are following the tutorial and its not working, then that tutorial may have a bug in the code the are recommending. That or maybe a step got missed. Hard to say.

burnt axle
#

@cedar cloak Just read the guides from Photon itself, they are pretty good and gets you going right away. Tutorials on Youtube might be good at times but they can also be outdated so make sure they are up to date first. But i would recommend reading the guides and docs from Photon itself, as its more updated and accurate.

slim ridge
#

i hate scrubbing youtube videos for that one nugget of information you need xD

#

always prefer text tutorials with images

jade glacier
#

Video tutorials should ONLY be used for initial workflow overviews. They are terrible otherwise.

burnt axle
#

Attach it to a empty gameobject, and click on the GUI buttons to connect, join a lobby and then create a room

#

You might have to wait ~1s before clicking the "join lobby" button, because Photon needs to connect to the cloud properly first

slim ridge
#

that might be his problem right there

jade glacier
#

That is a design flaw in that tutorial

#

LOL asking the user to not push buttons too fast.... good design.

#

That is like the first online shopping stores asking users to not click "Buy" multiple times if the site isn't responding

#

The callbacks handle all of that timing, so that shouldn't be a problem

#

The prototyping components built in can be extended

burnt axle
#

Of course you use callbacks in a game ready script lol, i just put something quick together just to see if it connects at all

delicate shard
#

any idea on how to make custom registration and login

burnt axle
#

You need a database and a GUI with scripts attached that threates the user data.

delicate shard
#

have server n database setup but not sure how to setup the code for registration n login

burnt axle
#
  1. make the GUI that can recieve user input
  2. threat the user input (validation and sanitazion and other checks)
  3. save data
  4. prompt user with a status message (successfull/fail)
#

I dont think anybody here will show you step by step with code on how to set it up, you need to google this. What we can help you with is specific questions

delicate shard
#

any idea where i can get much more info on this

slim ridge
#

you mean like sending http requests?

delicate shard
#

i have api where i want to send and receive details from

#

http request it is

#

googled for this but didn't find much info

burnt axle
#

What kind of API?

delicate shard
#

sorry url

burnt axle
blissful fractal
#

I'm not crazy, UNET HLAPI didn't vanish from Unity last night or something, right? I'm just having some big issues with my packages if suddenly Visual Studio can't find any of the references, right?

burnt axle
#

@delicate shard Seems like the tutorial goes over everything except the HTTP requests, but you can follow the tutorial and extend it with your own HTTP requests. C# language already has HTTP classes and such

jade glacier
#

its been removed from Unity for a while. Newer versions you have to specifically add it to your project.

blissful fractal
#

but I didn't upgrade the version of Unity between yesterday and today

burnt axle
#

@blissful fractal I hope you are aware of that UNET has been deprecated a long time ago and its probably loosing support really soon. Time to switch if you are using a production game ๐Ÿ™‚

blissful fractal
#

they wouldn't slice it out of versions that had it

#

oh I know

#

I'm being an idiot in that regard

#

I WAS hoping to ride it out while I tinker until the new unity solution is out and well documented

delicate shard
#

@burnt axle yeah that's what i was looking at that tutorial got nothing on http request, btw thanks for the share ๐Ÿ˜„

jade glacier
#

If your project was already making use of it, I think it stays in as a package... but I have no real experience with trying to work with it past 2017 @blissful fractal

blissful fractal
#

lol

#

yeah

#

ok, I'm pretty sure dropbox just jacked the packages

#

but I wanted to make sure

#

I guess I'll go ahead and just switch to photon

burnt axle
#

The new Unity multiplayer framework is already out

jade glacier
#

"out"

burnt axle
#

Looks like its only avaible for paying customers?

jade glacier
#

Preview Alpha .000001 ?

#

Or like with the words Preview actually removed?

burnt axle
#

Yeah, pretty fresh

slim ridge
#

or use .Net and write your own protocol ๐Ÿ˜„

blissful fractal
#
  1. Yeah I usually need my hand held a bunch on networking, so jumping in to it while it's still so fresh is a recipe for disaster.
#
  1. if I wrote my own protocol, I might break the internet
slim ridge
#

what's more fun than breaking the internet?

blissful fractal
#

fair enough

#

I'm still kiddy pool, maybe I'll get there in a bit

#

I'm not TERRIBLY intimidated by writing my own, but I just think it would be a waste of everyone's time until I feel more comfortable with networking in general

slim ridge
#

there are some advantages

  1. you will understand whats happening end-to-end and have complete control
  2. you dont have to do unnecessary things to fit within the confines of whatever prebuilt solution you use

like with photon people have trouble finishing the tutorial cause there are a lot of parts they assume will "just work"

#

but if you want to get your feet wet, look up google protocol buffers ๐Ÿ˜„

jade glacier
#

There is nothing wrong with using complete or partial stacks of existing net libs when getting started into networking. Networking involves about 5 layers of API, and learning any or all of them has value.

blissful fractal
#

well, maybe I'll give it a shot

#

can't ignore ALL the encouragement!

slim ridge
#

Unity -> photon -> .net -> tcp/ip -> os

jade glacier
#

There are the aspects new net devs don't want to write. Like the layer above the transport is the objectID/conduit layer for identifying objects, and their owners and dealing with directing messages to the right destination objects.

Then there can be a layer above that that deals with tick/simulation and timings involved in that.

And there can be layers above that that have premade components and codegen to actually make for codeless UX.

blissful fractal
#

all that sounds interesting for sure, just a matter of where to start

#

I'll do some googling and see where I land!

#

โ™ฅ๏ธ

jade glacier
#

Just start with the standard libs and tutorials.

#

Once you get comfortable with those, higher and lower concepts will have more meaning.

blissful fractal
#

๐Ÿ‘

jade glacier
#

to start learning about the concepts, but applying them is still a long way out.

blissful fractal
#

yeah for sure

slim ridge
#

i'm building a physics server/client with deterministic lockstep it's really difficult

blissful fractal
#

I'm hoping only for 2d games

jagged flame
#

Hi, I'm just starting to learn tools for working with the network. There is a task - it is necessary to initiate broadcast push notifications to all available devices with the application. Something like an emergency alert that is triggered on the server. Is it possible to implement using the functionality of Unity libraries? If so, please tell me which side to look for?

slim ridge
#

this is actually handled at the device OS level. Android and iOS have their own methods of pushing notifications

#

You'll have to go through the nightmare of setting those up in your app and in your server

jagged flame
#

Thank you, so I have to delve into the native functionality of OS. Bad news.

amber trench
#

@jagged flame you should probably just go with a push notifications wrapper service

toxic lintel
#

does a server need a port number from the client to know where to send the data?

#

or is the only neccesity for a port number when a client tries to send data to a server

amber trench
#

@toxic lintel when a client connects to a server using tcp/ip on a known port, the server has a two-way connection

toxic lintel
#

alright

amber trench
#

is that helpful?

slim ridge
#

wrapper services can get expensive beware

amber trench
#

@jagged flame if you're only targeting android you probably want to just use what google provides through firebase

toxic lintel
#

yea i think that means yes

#

right

#

also ip adress points to a specific machine right

slim ridge
#

or group of machines

#

but yaeh

amber trench
#

@toxic lintel what's your objective? to give someone a text box, in their game, for which "host" to connect to?

jagged flame
#

Found api for a similar functionality - plexure. Maybe itโ€™s not so difficult. I will continue to explore the issue. In general, in order for the server to know about the client, you need to communicate regularly, which is not good. Or somehow there should be a list of clients on the server

amber trench
#

that only really works on local networking (LAN) in practice

toxic lintel
#

no I am trying to learn more about networking in general

#

am i going in the right direction with socket programming

slim ridge
#

yeah

amber trench
#

@jagged flame don't worry my dude i can read russian at a 3rd grade level ๐Ÿ™‚ i like urban airship (now airship)

#

the server does maintain notification lists, yes

#

that's all the right idea

jagged flame
#

))

toxic lintel
#

thanks for the help btw

amber trench
#

@jagged flame the external services do a good job of knowing like, how many times to ask the device for notification settings, etc.

#

they keep an updated list

jagged flame
#

thanks for the discussion, I hope that there will be no bureaucratic problems using external services\

amber trench
#

Yes thatโ€™ll be a super good one for Android

weak plinth
#

can anyone help me? i'm new to unity multiplayer and the character doesn't spawn.

slim ridge
#

not without more details

weak plinth
#

alright just a second

#

if there's anything else you need tell me

slim ridge
#

i have no idea what that is

weak plinth
#

hold on

#

nvm

#

the camera was on a different layer than the player

civic stream
#

ok I'm back

#

same issue

#

this time I'll just paste my entire code

#

if someone can tell me why this isn't working I'd give you a high five

#

assume all variables are properly declared

jade glacier
#

You would need to say what you mean by "isn't working" specifically, and point out what part of the existing code is where you find it is breaking when running debugging

#

If you aren't good at debugging yet, I would STRONGLY encourage not trying to develop a multiple player game. They are considerably harder to debug than a typical single player unity game.

civic stream
#

ok

#

so

#

I managed to get one RPC call working

#

a really simple one

#

it just sends a float which increases in size

#

my player.cs script was able to receive the RPC and print out the updated variable

#

but for some reason, even if I disable my test RPC method

#

my new one just doesn't work

#

there's no difference other than I'm sending an int rather than a float

jade glacier
#

can you remove all pronouns from that question though?

#

hard to say without know what "my test RPC method" means in context of the various connections and such.

civic stream
#

its also not overflowing the buffer because the PV.RPC is called once

#

its just a simple RPC method

#

[PunRPC]
void RPCFunction(float syncVar)
{
SyncVariable = syncVar;
Debug.LogError("SyncVar changed! " + SyncVariable);
}

jade glacier
#

and its replicating as expected?

#

That logerror is firing where expected?

civic stream
#

yep

#

everytime without fault

jade glacier
#

So what is "the new one" ?

civic stream
#

RPCSyncColours()

jade glacier
#

What are the arguments in that and you set it up in the PUN settings as a known RPC type or whatever is needed to be done there?

#

I don't actually use RPCs in PUN, so I don't know what is involved.

#

But I know it doesn't weave, so something has to be wiring up the RPCs

#

its not weaving and its not codegen, so I assume reflection?

#

Looks like just the declaration is all that is needed, so I assume its reflecting behind the scenes and producing a RaiseEvent(yourArgsAsBoxedObjects[])

#

So what does your RPCSyncColours() look like in code?

civic stream
#

its in the pastebin

#

I'll paste it again

#

[PunRPC]
void RPCSyncColours(int ID)
{
print("Changed colours");
}

#

this is how it looks on my gamemanager.cs

#

[PunRPC]
public void RPCSyncColours(int ID)
{
print("added colour " + ID);

    PhotonView colour = PhotonView.Find(ID);

    colour.gameObject.transform.parent = this.gameObject.transform; //set colour to this object as child

}
jade glacier
#

I believe int is a valid argument primitive

civic stream
#

this is how it looks on my player.cs

#

wdym

#

its valid?

jade glacier
#

yup, int is legal

#

You have the same named method in two places?

civic stream
#

yes

jade glacier
#

I would avoid that

civic stream
#

in two different scripts

jade glacier
#

without knowing what is behind the scenes with hashing, that is not a risk you should be taking while debugging

civic stream
#

but it worked with the test RPCFunction()

#

ok i'll try

jade glacier
#

If you call the RPC inside of the class it is in, does it work?

#

attribute based syncvars and rpcs are typically a minefield of things that can break them.

civic stream
#

its not given the [SyncVar] attribute

#

its just a normal float

#

unfortunate naming on my part

jade glacier
#

SyncVar?

civic stream
#

yes

jade glacier
#

I just missed the lane change, we were debugging your rpc

civic stream
#

also the RPCSyncColours() method isn't being called in the gamemanger.cs script

#

yes

jade glacier
#

There is no syncvar in PUN is there?

civic stream
#

the syncvar is just a name for my variable

#

no

jade glacier
#

I added them to SNS, but they arent there

#

ah

civic stream
#

srry unfortunate naming

jade glacier
#

So if you call the seemingly broken rpc from inside of its own class does it work?

civic stream
#

nope

#

[PunRPC]
void RPCSyncColours(int ID)
{
print("Changed colours");
}

#

that print statement isn't called

jade glacier
#

PV.RPC("RPCSyncColours", RpcTarget.Others, playerColour.GetComponent<PhotonView>().ViewID); //pass ID

That call you are making, you are indicating the correct PV? And this would also indicate that you should not be using the same name in two places

civic stream
#

I'm not

#

private void Start()
{
PV = GetComponent<PhotonView>(); //create inital PhotonView object to reference later
}

#

I only have this

jade glacier
#

that should be the right PV. Having identical names would definitely break this.

civic stream
#

doing "this.photonView.RPC" and "photonView.RPC" doesn't work either

jade glacier
#

since no reference to the component is given, there is no way the PV would know which you mean... so it doesn't even care. There is one RPC per string name

#

this has no value in this context

civic stream
#

but even after disabling the other RPC call, it still doesn't work

jade glacier
#

you changed the name to make sure there are no repeats of the same spelling?

civic stream
#

I declared "private photonView PV;" at the beginning

jade glacier
#

yeah, the pv is fine

#

have you changed the method names to be unique?

civic stream
#

I'll try changing to something completely random

jade glacier
#

so that is a no

#

that is broken

civic stream
#

but they are unique

jade glacier
#

that is all that matters

#

if they are unique, then that isn't the issue

civic stream
#

yep tried spamming random letters and copying the RPC method name

#

still nothing

jade glacier
#

The method is definitely being called?

#

on the calling side of the RPC?

#

A debug there would be good to make sure its not some other bug

civic stream
#

unity isn't stopping at PV.RPC()

#

I put a print statement right after

jade glacier
#

I wouldn't use stops while networking... that will just break things completely

#

I tend to stick with Debug.LogError

civic stream
#

nono I mean that it doesn't freeze at the call

#

its not supposed to

jade glacier
#

So the PV.RPC() is getting called?

civic stream
#

but I've had an issue where unity would freeze at some networking call before

#

I'm assuming so

jade glacier
#

I would check that

civic stream
#

how do I check?

jade glacier
#

otherwise you may be debugging nothing

civic stream
#

if the method its trying to reach isn't reached?

jade glacier
#

put a debug in front of it and make sure control is getting there

#

Debug.LogError every possible step of the way

#

this kind of guessing will take hours at this rate

#

Seed the entire path of operations you expect to happen on both sides of the network

civic stream
#

it is

jade glacier
#

Yeah, let's not do that. Debug the crap out of it.

#

So you can isolate exactly where code stops doing what you expect

civic stream
#

I know where it stops

#

or at least where it skips

#

it just skips the RPC call

jade glacier
#

You are certain then control is getting to that call.

civic stream
#

yes

#

it gets there but nothing happens

jade glacier
#

You have put a debug right before it and it indicates control getting there.

civic stream
#

I put a print statement

#

unless debug works differently

jade glacier
#

Not sure why print

civic stream
#

WAIT HOLD THE FUCK UP

#

I THOUGHT IT DID

#

I swear it made it to the call

#

looking over it looks like it stopped right after I did some list indexing

jade glacier
#

With networking this will happen a LOT

#

assume nothing. Seed debugs all over the place. It often isn't broken where you think it is.

civic stream
#

I'm actually face palming

#

the entire if statement

#

that is enclosing the rpc call

#

isn't actually running

#

it assumed that the player would add itself to the playerlist upon spawning, but in order to spawn it had to wait for the RPC call

#

which was in the if statement

dusk basalt
#

Can somebody explain me how to sync a lineRenderer with Photon ?

jade glacier
#

With rpcs with vanilla pun. Or you can try SNS and use Syncvars.

dusk basalt
#

Thanks, I have to read some stuff about it first :)

dusk basalt
#

It actually worked thank you man ! Didnt expect its that simple

spring crane
#

Has anyone built to WebGL on PUN Classic 1.102? NetworkingPeer:818 is trying to set SocketWebTcp.SerializationProtocol, which is inaccessible.

gray pond
nimble eagle
#

I'm using Photon PUN 2, and I'm having trouble figuring out how to refresh my lobby on will!

So, basically, I've had networking set up for a while: Now, I've recently set up a lobby system to give my game more control over which room is joined. When I join the master server, I use PhotonNetwork.JoinLobby(). Then, when it's connected, in my Lobby Script the OnRoomListUpdate() callback is called, which caches the room listing. This works great, and I have a stored record of the names of rooms and number of players in them! I then use that data to choose and join a specific room

Now I have an issue though: While a player is in-game and inside of the Room they joined, I want to still refresh and get the updated lobby's room list, so they can see other rooms available while in-game. The issue is... OnRoomListUpdate() never hits again. I can't figure out how to force a refresh when I need it... or get any refreshed data at all after the first time!

For example, say there is a situation where there are no rooms yet. A player connects to MasterClient, and joins the lobby: OnRoomListUpdate() is called, and reports that there are 0 rooms at the moment, which is accurate! So, the player creates and joins a room. Now, in theory, it should report that there is 1 room, since we just created one... but the OnRoomListUpdate() callback never triggers again, and I can't figure out how to force refresh that listing in any way.

Does the lobby stop working once a player joins a room? I've tried a bunch of things, including even leaving and re-joining the lobby, which has zero effect (doing that won't even trigger the OnLeftLobby() callback, which is weird). I want to keep accessing the lobby and have it refresh OnRoomListUpdate() while the player is in-game, how do I do this? Is there something I'm missing?

nimble eagle
#

I've done some more testing, and it seems that as soon as I create/join a room, "PhotonNetwork.LeaveLobby();" stops working, and will not call the callback "OnLeftLobby()".

TL;DR: It seems that the Photon PUN lobby just stops working as soon as a room is created/joined. I'm... uh, not really sure why it's made so we can't keep accessing the lobby info after we join a room... ๐Ÿ˜…

Does anyone know any sort of work-around? All I want to do, is (After the player has already joined/created a room), be able to get a list of all available rooms, with the room names and number of people inside, so I can know which to join. Does anyone have any ideas? Thanks so much, I know this is a long shot!

jade glacier
#

I never use lobby, but when you join a room you are connecting to a different server. The game server and matchmaking server are two separate things is my understanding.

#

Not sure if there is any easy out soon hacky way to create a matchmaking server connection while in a game, but I don't it.

nimble eagle
#

Yeah @jade glacier , I'm super confused why we can't just see the listing of all rooms after we joined a room... ๐Ÿ˜… Thanks for the response!

jade glacier
#

You could cache it. But it's literally info you get while connected to a different server. When you join a game that connection is dropped to the matchmaking server, and you connect to the room server.

#

There might be some way to poll the matching server other than connecting, but I have heard nothing about that.

nimble eagle
#

Drat, caching isn't an option since I want live updates on the statuses of rooms... I want players to be able to see if there are other rooms with more people in them, and select to join those rooms if they want

jade glacier
#

@stiff ridge might know a way. But he will be offline for the weekend.

nimble eagle
#

Okay thanks!

#

It's a shame, I even made a super nice UI for it and everything ๐Ÿ˜…

nimble eagle
#

If anyone else knows a way (Photon PUN) I could get an updated list of rooms while already inside a room... Please let me know! Thanks!

gleaming prawn
#

That is not possible for the reason emotitron posted

#

Photon does not offer a specialized matchmaking solution.

#

If you want to create custom matchmaking stuff, you can use playfab of others and use photon for the realtime part

civic stream
#

@nimble eagle you could tell all the players when a new room has been created

#

and have them update their own list of rooms

slim ridge
#

have you considered running another "client" in another thread that just joins the matchmaking server when you enter a room?

#

then you just keep swapping clients when they leave/enter rooms

nimble eagle
#

Thanks, those are good suggestions! I realized I could just put room joining before the player enters a room without too much difficulty, it still solves the original issue I needed to solve; Thanks for everyone's help!

dusk basalt
#

Is it possible to get the "PhotonNetwork.LocalPlayer.UserId" from another client via the Raycasthit ?

slim ridge
#

I'd make sure the UserId is a property of the object being hit

jade glacier
#

The photon view keeps that yes

slim ridge
#

hit.transform.gameObjectis that what you're looking for?

jade glacier
#

Get to the hit objects pv, and find it's player id

#

Also known as the actor

dusk basalt
#

I actually save the ID in the start Method of the Object ; clientID = PhotonNetwork.LocalPlayer.UserId;
then i save the ID of the Player that got hit by the ID: hookedPlayerID = hit.transform.GetComponent<AdvancedWalkerController>().GetClientID();

Then I call a RPC : photonView.RPC("RPC_AddForceToPlayer", RpcTarget.All, _hookObjectVelocity, hookedPlayerID);

and in the RPC I compare the two IDยดs : if (string.Compare(clientID, GetClientID())== 0){ //Do something};

#

but it seems to send the wrong ID ... the hookedPlayerID is the ID of the Player who shoots the raycast and not the Player who got hit... Any suggestions ? :)

jade glacier
#

I can't comment on that. Your GetCliemtId() isn't pun code and I can't see where it is getting its value.

dusk basalt
#

GetClientID() just returns the saved clientID from the Start Method

jade glacier
#

Too much unseen code. But if you shoot someone and want that someone's connection I'd, you get that from the objects pv.

#

What is client Id?

#

That isn't a pun term

#

And start is a risky place for net code. That should all happen in OnJoinedRoom

#

Unless you are certain that object will be spawned only while already in a room

dusk basalt
#

Till now I am certain, but I will apply your tipps, and try to get it to work with the photonView stuff, Thanks man your great !

jade glacier
#

Remove all assumptions first

#

Then debit

#

Debug

dusk basalt
#

What do you mean with assumptions ?

jade glacier
#

You are assuming you are getting values, or cached values are correct