#archived-networking

1 messages · Page 66 of 1

jade glacier
#

If you make a deterministic system of your own, the library doesn't matter - they are all just messaging layers to you.

gleaming prawn
#

I was sure that most of RTS uses this model
This is not the "model"... It's just who is responsible for hosting the INPUT management

#

It's still lockstep

#

In most RTS, the "host" is just the input batching manager (so you get rid of the most common problems with 30-year old lockstep)

jade glacier
#

Most people new to networking never get this concept until way later and after a lot of refactors/restarts - Game Networking is about the simulation, not the messaging

gleaming prawn
#

yes..::)

#

In summary, there are several things being messed up in general, we need that post...:)

#

With no bias, and no preferences, just pure information...

jade glacier
#

Easiest route is just start a google doc, and rather than answer things here... just write them into that doc, and point people to read that.

#

yikes, I just said "word doc"

#

Almost put on my old man pants there

gleaming prawn
#

lol

verbal oar
#

That would be awesome because there are literally no structured and comprehensive info on these topics on internet

gleaming prawn
#

I contest this a bit

#

the problem is that the topic IS COMPLEX

jade glacier
#

gafferongames has great information, but its not about libraries. Though generally the "which library is best" talk is already on the wrong path.

gleaming prawn
#

And requires several tiers of tooling and understanding

#

gaffer on games is mostly great. although he has his "preferencies"

jade glacier
#

I think the first thing before anything is to understand what a complete networking stack looks like for the different game types.

#

Gaffer is just nice because he discusses a lot of the basic concepts in one place. Some of his old examples I thought were kind of down pointless paths... like his networking physics stuff.

gleaming prawn
#

The way he talks about determinism seems to "consider" 20 years of predict/rollback development worth of a couple of words (at least last time I saw)...:)

jade glacier
#

He definitely seems to live more in the snapshot interp world

gleaming prawn
#

exactly his networking physics... He uses lockstep when he should be using predict rollback...

jade glacier
#

He also stopped working on those docs, so I assume he knows more and better now - he just isn't writing any more.

gleaming prawn
#

And stuff like prediction culling, etc, nevermind...:)

jade glacier
#

It's inevitable. Giving away any of this knowledge is a lot of work with very little gain if you already have landed a sweet gig.

gleaming prawn
#

But don't get me wrong... Glenn is a great guy, and probably an inspiration for most of us here (me included)

jade glacier
#

I mostly just appreciated that he supplied great visuals and put the time in. Better to have a slightly incomplete reference... then no/scattered references. And appreciated that I could just point people there rather than answer the same questions over and over. 🙂

jade glacier
#

I just made a google doc where I am going to copy long winded answers to questions. Will see how good I can be about copy knowledge dumps from the channel into that.

narrow oriole
#

@verbal oar I would disagree. There are ton of GDC talks, articles, blogs, sources about networking

#

Probably bad luck finding information.

haughty trench
#

Hello everyone!
Quick (and newbie) question here. Is it a bad practice to use HttpClient from System.Net.Http instead of UnityWebRequest? I am writing a service and I would like to have no Unity's stuff in it.

haughty trench
#

I was using a lot of async/await code along with System.Net.Http.HttpClient but I thought I would have a not-optimal threads management and maybe this namespace is not available on some devices so I decided to go with coroutines and UnityWebRequest but I don't have enough experience to know if it's a good decision or not.
I can already see that one drawback of coroutines is it's more difficult to return a value. Don't get me wrong I know it's doable but it's less convenient than int randomNumber = await RequestARandomInteger();

urban jackal
jade glacier
#

That is UNet?

urban jackal
#

No thats unity transport package new update

jade glacier
#

I see they are using some of the old class names. Can't help you with netcode, haven't touched it. DOTS channel might have more people in the know.

urban jackal
#

👍

glacial totem
#

My physics based game wouldn’t be where it is right now without Gaffer

#

Idk how “outdated” his material is, but his articles about determinism and networked physics are all designs Rocket League uses

#

So outdated or not, we have a modern AAA game today that uses them with great success

#

(The most successful networked physics based game made so far in my opinion)

#

Just wanted to chime in there and say that @jade glacier @gleaming prawn

jade glacier
#

Rocket League goes quite a bit beyond the basics he discusses. But yes, his stuff is a very useful introduction to the concepts. I think we are all in agreement.

#

I'm not sure what you mean by Rocket League using his designs. He didn't make the concepts - he just did a nice job of illustrating them.

gleaming prawn
#

Rocket league is a great game, and a tour the force by its developers from all I read.

#

You can send messages to any client @weak plinth

#

Low level photon realtime messages

#

RPCs are how you said, but they are just awrapper around normal raw realtime.messages

#

My point is @glacial totem maybe we should have many more great physics games, besides rocket league. Maybe I'm wrong... And maybe I expressed.myself badly, I don't think his article is outdated at all, his descriptions are also excellent. I just think he chose not to explore one of the options all the way to the most modern approaches (IMHO).

honest zealot
#

wrong rob tagged lol

gleaming prawn
#

Sorry

#

Will fix...')

honest zealot
#

np

sour chasm
#

Any photon server experts over here?

spring crane
#

Some people here even made it 😛

#

Just ask your question

sour chasm
#

We are using custom server application that implementes room based networking (smiliar to loadbalancing). The issue if when we have more than 2-3 players in room, the movement updater on server if slowing down so much the client recives only 4-5 position updates instead of the needed 10/s. We implemented it like following:
Each room has updatedMovement list which collects all movements of actors each 105ms roomTick shedule. Then the server updates all clients about the position chabge by sending fullList to clients. The incomming rate is about ~10msgs/s but when 3rd player joins the incomming rate that client recives goes crazy down to 3-4/s for some reason

gleaming prawn
#

Have you profiled your code that does these updates on server?

#

There has to be something really bad going on either.on your update code or somewhere else for this to happen with this low player count. We run a few thousand players in one machine (Albion online does that as well)

#

The fact that you are implementing a server app based.on the standard load balancing arch, wouldn't you actually be well server by just using load balancing and normal room plugins on your self hosted photon server?

#

That might save you a lot of implementation details. You can run timer based updates on rooms, etc... We do this for our base quantum plugin (at 60hz by default, much faster than yours)

#

I mean, I've been implementing photon server.room plugins for the past 3 years and I know ofmcourse how to reach its limits. It's just a lot higher than this...

sour chasm
#

well, take a look at the RoomTick() code its like that

blissful fractal
#

if I'm instantiating a bunch of map tiles OnStartServer, do the tiles HAVE to be local player authority? It seems like the server should own them, but when I do that only the host gets a map

high night
#

https://gfycat.com/lavishfalseasianlion
I've been trying to port the new stateless ECS's Unity.Physics into monobehaviour classes and gameobjects

This is client's view
Client recieves a new state from server at 5hz
Reverts back 10 frames, resims 10 frames when a state is recieved (lives 10 frames ahead of server)
There used to be harsh corrections on objects before on each state recieve+rollback+resim, but ecs physics really seemed to have fixed the issue for me.

#

Cubes are a little slippery but thats because Unity.Physics doesn't support "stacking" yet i believe

#

I did my byte by byte state comparion before and after 10 frame rollback+resim for same timeframe
It seems to be always same until a another player changes it's input
edit: I tried moving around, shooting arrows and doing the byte check on every rollback+resim on clientside, i seem to get a different result in check every 15 seconds or so, i don't know why yet

vital hawk
#

"yet" isn't accurate

#

it will never be great at stacking

#

they already fixed the initial issues where you couldn't even stack 3 cubes

#

but there's only so much you can do without cache

high night
#

@vital hawk
What do you mean not accurate?

spring crane
#

Probably as in that is the stacking support. Expecting some sort of big gains in this area in the short term might be iffy.

high night
crude night
#

hello i am still trying to create and understand udp socket networking with csharp
first I would like to know if I am on the right track, then I would like someone to help me understand what I do not understand,
if someone has a few minutes to grant me here are the scripts
Player and Client: https://codeshare.io/G8KoXB
Server: https://codeshare.io/5Q1LZ7
and i'm sorry for my bad english
thank you

vital hawk
#

@high night yeah I mean, they can't do wonders with the stacking without having some sort of a cache, and that's against the stateless design

#

so, wouldn't expect the stacking ever to be even comparable to what physx or havok has

high night
#

yeah, right

gleaming prawn
#

That's pretty much it... I talked a bit with the guys from havok, because our engine is also stateless... And that's pretty much it.

#

You get some basic stacking, but not as close as what you can do with caching collision data over time

rich flame
#

hello, so i just switched from mirror to photon recently and for some reason cant connect two people to the same server, however i do get this error

#

im trying to use ConnectUsingSettings()

#

ill go to sleep anyways and try to figure it out tomorrow

jade glacier
#

First thing to try for that is set the Fixed Region

#

Its possible for the editor to come up with a different "best region" than builds first run. A Dev Region is being added in a release soon to deal with that since it happens so often. @rich flame

#

Though that error suggests something else.

spring crane
#

Make sure nicknames are unique

rich flame
#

Ok thanks emotitron and danny, ill try those tomorrow

amber trench
#

@high night my feeling is that if you're having issues with Unity.Physics at some lenght of time, like 15 seconds, i feel like they probably have tests for this, so maybe share the scene with them

high night
#

@amber trench It's very likely this is my fault, that seems to happen at the same time i get a lag spike
I'm thinking it's changing how the inputs are applied locally and sent to server
Or maybe server lagged and missed some inputs
I'll try to debug my inputs further
I was expecting better determism on same machine

clever hinge
#

anyone know any videos i can use to make my game multiplayer?

#

im trying to use unet but idk what to do with it

spring crane
#

I'm sure you can find some if you search for them. I recommend making few singleplayer games first to get comfortable with C# and programming

clever hinge
#

what about lan? is that easier

haughty trench
#

@clever hinge I am not an expert at all but I don't think it's far easier since you always have to sync games, to send packages etc. It is easier because you may have a lot less issues with your network but you still have to deal with a network, it may only be more reliable. I think !

spring crane
#

Yea it's just a lot to chew at once. Making games is already hard

clever hinge
#

ight

haughty trench
#

Hello everyone.

I cant post all the code here so as you read you can check out this hastebin: https://hastebin.com/icesiyunes.cpp

I am very new to unity and networking using C# and its been 2 days since I started to struggle with some really basic issues. I think I need help. I have a service that can do web requests.

see service's method on hastebin

Pretty simple. I want to be able to execute multiple web requests synchronously (one after the other) using coroutines and I want some service's methods to be able to return data from their coroutines (yield return toto). In order to do that, I am using a wrapper for coroutines that can returns data.

see calling the service on hastebin

The wrapper comes from this topic :https://answers.unity.com/questions/24640/how-do-i-return-a-value-from-a-coroutine.html

I have multiple issue :

  • the synchronous part does not works as expected. The 2nd request does not wait for the 1st to finish.
  • I have modified the wrapper so I can pass a generic type to it that define the type of data returned by to coroutine. But I don't know how to make it generic.

see coroutine wrapper on hastebin

You can look at the commented code to understand my issue.
Here is what I have tried to do to fix it.

while (target.MoveNext())
{
    if (typeof(T) == typeof(string))
        result = target.Current.ToString();
    else
        result = (T)target.Current;

    yield return result;
}

But it's just not a valid code.

I just don't understand how to write services that can be called both sync and async (up the to caller) and return datas. Sorry!

#

(Oh and thanks a lot for reading this already too long question. Even if you don't have answers but just samples or resources its already welcome of course!)

amber trench
#

yes @high night for networked physics, you will almost always have to do something of the form of

  • client sends input packet tagged with last packet number received from server, client-side simulation occurs normally
  • server buffers packets during its timestep from clients, executes client inputs in order to compute physics
  • server sends collected, authoritative inputs with with incremented packet number, client reruns physics
  • server discards inputs sent with earlier packet number (the time to send your input has elapsed)

if you need to hide physics objects from some clients and not others, this obviously gets really complicated

#

your life would be made easier by unirx

high night
#

is unirx for controlling monobehaviour update callback?

jade glacier
#

If you aren't going fully deterministic you can constantly clean up the PhysX disagreements with state transfer. But that is never REALLY networked physics.

#

I don't think there is any such thing as networked physics, it implies something that can't be.

high night
#

@jade glacier i did try that
cleaning up doesnt do it, physx cache needs to be serialized somehow

jade glacier
#

Either you are predicting physics and cleaning it up with server states and resims... or you are deterministically extrapolating and doing a lot of resims.

#

For the deterministic side you aren't networking the physics though, you are just being deterministic

#

It will never reach 100% agreement

#

you are just using the state sync to get things in BETTER agreement

#

Thus why deterministic is the ultimate.

#

I have had luck in the past with tests of syncing using just rb transform and velocities, where things stayed in agreement more than not

high night
#

Rigid collisions usually don't work with the rollback/resim with physx i believe

jade glacier
#

This hot mess is hard to see, but basically when the spheres show lines coming out of them they are in disagreement. So you can see that they got back into agreement in one frame and usually stayed that way until the next collision.

#

I don't think I would want to build a game around that mechanic though.

#

That was PhysX btw with partial resimulation (separate physics scene that resimulated just one ball at a time against copies of the world colliders)

high night
#

oh, sounds funky

glacial totem
#

@high night resim works fine with PhysX

high night
#

you have to deal with collisions

#

oncollision enters

#

collision forces

#

or any kind of addforce

glacial totem
#

What do you mean?

high night
#

they are cached and applied next frame

glacial totem
#

My game uses all that stuff

glacial totem
#

Not sure what that means

high night
#

if you increase your prediction frame count, don't you see harsh corrections on client side?
even though there isn't any other player input change

glacial totem
#

What do you mean prediction frame count?

high night
#

how further client lives ahead of server

glacial totem
#

That should only be the latency of the client though

#

If a client has 33ms of latency to the server, they should only be 33ms into the future

#

Also yes, the more latency a client has, the more harsh the corrections will be

#

But I don’t know what AddForce has to do with anything

high night
#

even if client has 500 ms latency,
if all players except this client are keeping their inputs same
this particular client shouldn't ever see any corrections at all

glacial totem
#

Correct

high night
#

I believe this will be very much possible with unity.physics

glacial totem
#

A 500ms client in the game with no other players shouldn’t see any latency

#

It’s also possible with PhysX for the most part

#

It’s very dependent on your physics simulation

#

What does AddForce have to do with anything though? Lol

high night
#

in practise yes,
but i like this rocket league physics because i just think it's easy because you don't ever have to deal with individual cases when you write netcode

#

if my arrow collided with enemy at frame: 500, it should always be frame:500 when resimmed

#

and with same force

#

@glacial totem

#

listen to this:

glacial totem
#

That shouldn’t effect anything though

high night
#

no,

#

when you load a new state, these addforces will be carried over

#

you see the problem?

#

that's a big problem

glacial totem
#

It’s not though

high night
#

oncollision calls are also leaken into the next state you are loading

glacial totem
#

If you still have cached states, you did something wrong

high night
#

and i do my damage dealing methods in oncollision

glacial totem
#

You shouldn’t have any cached states if you called Physics.Simulate

#

If that’s not the case, you aren’t doing thing in the correct order

#

Physics.Simulate should have already been called for the the previous tick before you do any resim or rollback for the next tick

#

So that shouldn’t be a problem

high night
#

Physics.Simulate will invoke OnCollisions
Next Physics.Simulate actually will call the callback

glacial totem
#

@high night did you disabled Auto Simulation?

high night
#

yes

glacial totem
#

You must have done something wrong? I don’t experience these problems

high night
#

You are saying Physics.Simulate will clear the addforces, call all OnCollisionCallbacks?

glacial totem
#

From my experience yes

high night
#

So you do the serialization right after a Physics.Simulate

glacial totem
#

What serialization?

#

To send from the server to the client?

high night
#

position, velocity etc

#

yeah

glacial totem
#

Yes you should t be sending data until you call Simulate()

#

Same with saving the state locally for comparing corrections

#

You also should be getting fancy and quantizing your physics data

#

But that needs to come after you get everything else working

#

Quantizing will make everything even more deterministic

high night
#

I tried quantizing, it made my objects slippery 😄

jade glacier
#

I quantized it all for that example video above as well, should have mentioned that. Since the networked values were lossy, I would apply the lossy networked value to the server. Which also probably had a stabilizing effect on the simulation.

glacial totem
#

Def

high night
#

you quantize every simulated frame or or for every sent state?

jade glacier
#

every captured state, so could be every tick or every X ticks if the networking was set to send every X

#

Basically I would apply to the authority version exactly what was being sent to others.

#

Which likely would cause what you witnessed... slippery objects 🙂

glacial totem
#

I would do every tick

#

100%

#

No reason not to

jade glacier
#

If my server is only sending every X Sim ticks, then quantizing in-between frames would break things

#

The goal being to do exactly on the player side what you do on the server

crude night
#

hello, does the server have to simulate the same thing as the client? I mean do they need that the server contains the map to detect the collider etc?

pure vector
#

anyone used mirror for networking?

#

trying to set it up but when someone joins all other players start falling through the ground

crude night
gleaming prawn
#

@pure vector you should join the Mirror Discord

white walrus
#

Hi All, anyone knows what is causing this in my hierarchy? I get all these "not loaded" scene items..

fair cosmos
#

@gleaming prawn ? are u single person who develop photon?

#

if not how much of u guys are working for this framework?

gleaming prawn
#

Exit Games is ~50 people

#

Just the team developing Photon Quantum is 10 people (I'm only one of them)

#

So NO, I'm not the single person developing photon (I'm not even a developer of photon server or photon realtime, etc)

#

There are at least 5 or 6 of us in this Discord server alone.

rancid anvil
#

How could I sync a health bar

gleaming prawn
#

You sync the health, not the bar

#

The bar would look correct on all clients then

#

if they should see that entity/Object

#

Bar is just UI

gleaming fossil
#

Have a small issue regarding interpolation. I made a system in which packets are always ordered, so the players always interpolate to the latest packet. One issue I had yesterday was that I would get small stutters, rarely but they would happen. The code in which I am interpolating is as such:

float timeSinceLastInput = Time.time - deltaT;
 float t = timeSinceLastInput / Time.fixedDeltaTime;
 transform.position = Vector3.LerpUnclamped(this.netObject.lastPacket.position, this.netObject.currentPacket.position, t);
 transform.rotation = Quaternion.SlerpUnclamped(this.netObject.lastPacket.rotation, this.netObject.currentPacket.rotation, t);

Works insanely smooth most of the time, just the occasional stutter that ruins everything. I read in some articles that it could be caused by the interval between server updates not being constant, although I can't see how that would affect it as it would just keep lerping with the t value

#

deltaT is Time.fixedTime when the client recieves an update from the server

jade glacier
#

Your t is not ideal

#

If you are using fixed update as your timer, you need to consume every fixed. Update should then use (time - deltatime) / fixeddeltatime

rancid anvil
#
    public void RpcTakeDamage(float d)
    {
        if (currentHealth <= 0)
        return;

        //ONLY SERVER CAN CALL
        currentHealth -= d;
        healthbar.localScale = new Vector2(currentHealth * 2, 3);

        if (currentHealth <= 0)
        Die();
    }

    [Client]
    void Die()
    {
        //client side death
        Debug.Log("died, on client.");
        CmdDie();
    }
    [Server]
    public void CmdDie()
    {
        //server side call for death
        Debug.Log("died, on server also.");
    }```
#

What's wrong here ?

#

@jade glacier @gleaming prawn

#

On the take damage function

#
    void OnTriggerEnter2D(Collider2D col){
        if (col.gameObject.tag == "Player"){
            Destroy(gameObject);
            p = col.transform.GetComponent<PlayerScript>();
            p.RpcTakeDamage(projectileDamage);
            Debug.Log("You hitted a player");
        }
        
    }```
jade glacier
#

That's a lot to read without knowing what the error is we are scanning for.

rancid anvil
#

There is no error

jade glacier
#

Then it looks great 😛

rancid anvil
#

But even if i shoot to another player

#

It wont get damaged

jade glacier
#

That is the error then. Where is it not working?

rancid anvil
#

The bullet dont even collide with it

jade glacier
#

Use Debug.LogError for these dirty tests btw, and use Development Built in settings, so you can see messages on your builds.

#

And just test to make sure messages are getting where you expect first

#

I don't touch RPCs, so I don't know the ins and outs of them very well.

#

If the bullet isn't colliding, that is a physX problem

#

like your projectile is moving too fast for the collision to detect. Nothing in your code is going to work if you arent getting a collision

rancid anvil
#

ops

#

It didn't have a collider

gleaming fossil
#

Oh woops, sorry didn't disclose enough info emo 😅 The server events are triggered in FixedUpdate, the lastPacket and currentPacket is set as the server update event is triggered. The code I posted is ran in Update for each of the client players, same logic applies to the local predicted client where he moves

#

but you'd rather have it so that it's not

float timeSinceLastInput = Time.time - deltaT;
 float t = timeSinceLastInput / Time.fixedDeltaTime;

but instead

 float t = (Time.time - deltaT) / Time.fixedDeltaTime;
#

deltaT is assigned as such upon a server update:

player.netObject.deltaT = Time.fixedTime
#

A flaunt in my interpolation system might also be that the currentPacket is the latest received packet from the server, whereas I read most places that interpolation is always 1 behind 😅

jade glacier
#

Most recent received will defeat the point of the buffer, if I am getting your usage

#

The buffer is intended to smooth out the jitter of the internet... if you consume frames as they arrive, you are baking that jitter right back in.

#

If you are going to consume things right away you will be making a bit of a mess - but going that route you will want to make your lerps unclamped so that they can extrapolate if a new frame fails to arrive in time... but extrapolation is going to lead to rubberbanding.

#

Consuming right away and advancing the snapshot/targets... means you will have to keep some kind of track of where you were in interpolation prior. It gets messy.

gleaming fossil
#

I see... So instead I should take the 3rd last and 2nd last packet and interpolate between the two, once a new packet arrives, shift places

#

And yeah the latest thing is probably why it's s snapping

jade glacier
#

Typically you don't think like that... you just put them into a ring buffer (or something like that with a queue).. and you pull from that on the same tick that you generate frames.

#

Your deserialization uses the frameid to know which slot to store the frame into

#

If you go to pull a frame and that frameID is not there yet.. you extrapolate a frame... you don't just grab the next available

#

You will then add some code to monitor the health of the buffer... to see if its too fat/thin and adjust as needed over time.

#

For server based, the server never adjusts, so clients typically have to to do that - by repeating a frame to grow the buffer... or running two frames to shrink it.

#

Overwatch deals with the server buffer by having the server tell clients to speed up or slow down a bit until it is happy with the buffer.

#

Where the ring buffer becomes really important is when you are dealing with lost packets... because otherwise you will shrink the buffer every time you lose a packet if you are just pulling next from a queue.

#

Then later, you can get creative with missing frames... like if the frame after that arrived, you can recreate the missing frame by interpolating between the two on either side... etc

gleaming fossil
#

Yeah I see... Will try and get back to the drawing board, atleast I got a better understanding of my issue 😄 Cheers as always Emo

jade glacier
#

No problem. You are following the exact path everyone follows for this.

nimble eagle
#

I have a basic conceptual question! 🙂

I have position/animation/rotation multiplayer networking set up; Now, I want to add in melee combat PvP. On who's side should I determine if a player is hit by another player's attack?

For example, say we have two players, Y and Z. If Y attacks Z, who's computer do we detect for the hit on; Do we detect on Z's computer since they are the one who is hit, or do we detect on Y's computer, and send the "You were hit" signal to Z's computer? On who's computer do I register the hit collision?

#

(This is my first time setting PvP up!)

jade glacier
#

Are you server or player authority?

nimble eagle
#

What is the difference?

#

I am not sure which I set up!

jade glacier
#

You may want to read up on those, because that pretty much will decide how these things play out.

nimble eagle
#

@jade glacier I am still slightly confused which I am using. I network with Photon Engine PUN, and I use a matchmaking system to room players together; Then I use components like the Photon View and PhotoLocationView and my own OnSerialize method to send data. Which type would this be?

#

Would I be Server managed?

#

Also, which way is better for PvP?

#

Actually, I think I am Player Athority, right?

#

Yeah, I'm Player Athority my mistake 😅

#

How would I set it up with my Player Athority system? Who registers the attack collision, the attacker, or the person hit?

jovial rapids
#

never trust the client

glacial totem
#

trusting the client = trusting hackers

jade glacier
#

If it's casual or not competitive go right ahead and trust the client. Not everyone is making a AAA laddered competitive game. If you expect a lot of success and hackers, go ahead and plan for that... But way too often people get bogged down worrying about hacking, and never even finish a basic online game.

#

Pun is relay, so it's not conducive on its own for server auth. You need to write server plugins to make it such.

#

You can play with the extensions I am making for Exit that extends PUN2 to do most of what you are talking about. But it's not ideal for competitive PVP.

#

To answer your question, you basically have to decide your authority model.

#

Whichever connection has authority over a thing, is the final word for that thing. In server authority, the server is the final word for all things.

#

In PUN2 its mixed authority

#

So the shooter has authority over say their movement and their weapon. So they would shoot, determine what they hit, and broadcast that. Then whoever they claimed to hit would respond to that by applying that hit to their health... since players would have authority over their own health.

#

But again... This is describing PVP... which is NOT the ideal gametype for Relay.

nimble eagle
#

@jade glacier Thanks so much! Yeah, I'm going to keep it with Player Athority for now, since the PVP isnt particularly competitive and is more just a fun extra for now; I don't have the time or programming resources to set something like server side up right now and I may not need it a ton 😅

The main mode of my game is PvE, so it will be fine to stick with player Athority for now!

Thanks for the information and help!!

jade glacier
#

Server authority adds a lot of complexity, as you have to tie in your controller and physics code into your simulation and tick system. If you want to learn how to do advanced networking you can go there, but expect a couple years of learning and constant refactoring if you go that route.

nimble eagle
#

Good to know, thanks! I think the current Athority model should work fine for now, I can always upgrade later if I really need to and have the resources then 🙂

jade glacier
#

You can't really "upgrade later"

#

Doing server authority means creating a proper tick based simulation and tying in your controllers and physics

nimble eagle
#

I mean more like "Hard change" later 😅

jade glacier
#

If you REALLY plan on going there, start there now. Or use like Photon Bolt

#

good luck 🙂

nimble eagle
#

Thanks! You too!

hazy sage
#

Server authority adds a lot of complexity, as you have to tie in your controller and physics code into your simulation and tick system. If you want to learn how to do advanced networking you can go there, but expect a couple years of learning and constant refactoring if you go that route.
@jade glacier

Let's say I want to create the simplest form of this, though.

Just 2 spheres knocking each other off of a plane or cube.

How do you switch client authority or incorporate the other players rigidbody.velocity into your own movement?

#

Give us SOMETHING, even in the simplest form.
I like using Mirror, because it's simple like UNET. How would 2 spherical players knock each other off a board?

#

I have been trying to figure out the simplest form of networking & physics.

jade glacier
#

If you go without prediction, you just send inputs to the server, and the server sends resulting states to all

#

But that makes for nasty input lag

#

Which is why prediction becomes a thing... And that's where things get messy

hazy sage
#

I can make a Unity UNET/Mirror game where 2 players push a Cube with a Rigidbody around... but cannot make a game where 2 players push each other around.

#

A UNET/Mirror game where 2 players push each other around is what I am interested in learning more about...

#

... I want to understand and build a "Shove Your Enemy Off the Platform" Game. 1vs1

#

I tried OnCollisionEnter(Collider other){ if(other.collider.tag == "Player"){
if(other.collider.velocity > rigid.velocity){
rigidbody.AddForce(rigid.velocity -other.velocity)
}
}}

#

ROUGHLY along those lines, my code is way off... but I have tried some things within that scope.

#

IF OnCollision the other collider.tag is a "Player", add force depending on who's velocity is greater

#

But I must be barking up the wrong tree... because it works like for the first collision... but doesn't update the "pushed" players position on the Server

#

Clients & Opposing Forces.

If, however, I make a game where I just add a Cube with a Rigidbody, then both players can kind of compete in pushing the Cube.

#

But Client vs Client physics.... I don't get it.

#

I might even be able to Launch a Cube from one player to push the other player, but butting heads from player to player is beyond my understanding.

#

Most Multiplayer Games either have it where you STOP when you collide with another player or Clipping/Collisions with other players is simply turned off.

#

But I wanna be like "Move Bitch! Get out the Way!"

#

How do I accomplish Ludacris Multiplayer Physics?? Lol

#

using Unity Rigidbody.Velocity

#

or magnitude

#

?

#

I can maybe make it so

if(Player1.rigidbody.velocity > Player2.rigid.velocity)
{
Player2.clientAuthority = false;
}
else{
Player1.clientAuthority = false;
}

#

then once Movement.velocity > Rigid.velocity grant authority back to the client?

#

Is there any way to make something like that work?

Imagine 2 sphere's (Players) pushing each other off of a plane or cube.

jade glacier
#

Common objects like a ball in rocket league is very advanced

hazy sage
#

I can understand that, but there has to be some sort of tutorial or resources on how to accomplish it...

#

Rocket League can be narrowed down to Pong or Air-Hockey, but how do you do it in a Networked Mutliplayer game?

jade glacier
#

There is no one way, but the most solid is deterministic extrapolation

#

But also very difficult

hazy sage
#

No Easy Street on this one?

jade glacier
#

Nope, that is why mirror and other libs don't do it for you

#

Few people know how to make that kind of states correctly

#

You can and should try making it an easy way. It will make the correct ways make sense.

hazy sage
#

Those are good resources for learning Multiplayer Movement in Unity...
... but what about Client vs Client collisions?

#

at the end of that video he barely discusses rigidbody physics over the network...

#

It has to be more about locating the correct resources, rather than "Oh, it's really hard. Just give up."

gleaming prawn
#

The thing is, it is hard. And most good developers gave up giving advice...:)

#

Because the advice is hard... Resources:

  • start being a good programmer with solid foundations, really (this takes time)
#

Then there several good starting points, source networking blogs, gaffer on games, gdc talks online on the topic

#

Nine will be simple and fast to use

#

None*

#

This is why most of us give advice very seldom (because most askers want comfortable answers, some magic quick trick that will do the job)

#

Physics over the network is one of the hardest topics, FYI

#

In short, you either:

  • do a complex state transfer approach with local prediction (including remote objects).
  • use deterministic predict rollback
#

If you ask a more technical and specific question, maybe someone will answer with the details and references as well.

#

And if you liked unet's API (which was abandoned by unity), you can use mirror (the open source version of it, which is under active development - they have their own discord server though)

stray scroll
#

How would you generally solve "parenting"? I want to be able to pick up boxes basically, and put them in arms of player. The player can have different avatars, which are currently not synced, but I simply use headheight + rotation for camera. Since these boxes are dynamic otherwise, I'll need to do some changes on them when they swap as well. So I could use a system that runs after interpolation of net transforms to fake parent it to the arms of the characters, and on server I kind of does the same, and ofc removes collision properties. I could simply parent it to the character entity, but it might look ugly that it is kind of static compared to your character transform. Anyone got any ideas on this? I'm using ECS NetCode ;3 so trying to work within their framework as much as possible.

gleaming prawn
#

hmm, this is tricky

#

I mean:

  • if it's just for visuals of the object being carried, I'd make them a child of the local arms;
  • but yeah, if you want to resolve collisions (of the carried box with other stuff), you want these to be coherent with the visuals
#

So you can use the "fixed" offset approach, or actually make the server "aware" of the individual avatar hand offsets, etc

#

This is one of the elephants in the room TBH: you need Animation data + tooling to be tightly integrated to whatever netcode you do...

#

And the current state of animation on Unity is not looking super good.

#

In summary, the final solution would be:

  • integrate your animation/avatars to the client/server netcode, so you will have local parenting predict close enough
#

As long as the avatar position/rotation/animation time and state are part of the synced state, carrying the box would be done view networked "events", so you do not even have to sync the box position (of course)

jade glacier
#

For the system I am making for pun I do it with indexed mount components and a state sync that deals with things like re parenting. @stray scroll

fresh frost
#

Is the Dots Netcode something more special or what should I be googling to find tutorials?
I have found it very hard to find anything I can work with properly.
Anyone got an idea?

jade glacier
#

@gleaming prawn morning

gleaming prawn
#

Morning...

#

So your system also takes care of switching the "mounting" state of these objects between state-transfer vs being-carried-don't worry

jade glacier
#

yeah, and it has interfaces that coordinate all of that with the syncTransform

#

like it automatically injects a teleport and notifies the transform sync of the reparent

#

I debated whether parenting belonged as part of the syncTransform but it ended up being so tied to the state of the object (state being mounted, resting, spawned, visible, thrown etc) that it ended up there

#

Its sort of what I am hoping one day PUN2 will have a built in server plugin for - where the relay own objects and maintain that state.

stray scroll
#

Hmm, I currently have the state on both character and object. But I currently don't have some ID to the hand in any way, so I might have to start to actually add the avatars to the server and client as a start.

jade glacier
#

The mount mainly is just there to create a very small index value

stray scroll
jade glacier
#

like if you have only 4 mounts, you can network which mount with just 2 bits

runic rose
#

i cant understand !islocalplayer Can someone Help me???

fresh frost
#

@jaws with special I meant some different form to programm it, and thanks alot I will look into this

runic rose
#

can someone help me about !islocalplayer???

stray scroll
#

@fresh frost It's based on their DOTS framework, so you'll be using entities. So there are certain systemgroups (client,server,prediction), and attributes to put on your systems and components, and certain patterns to use.

runic rose
#

Please

gleaming prawn
#

@runic rose ask a technical question

jade glacier
#

Netcode as far as I can tell is a pretty boilerplate server authority with state transfer model. It just is working with some of the benefits of ECS memory alignment to automate some of the tasks.

runic rose
#

what you mean

stray scroll
#

@runic rose I think in UNET it is that the behaviour is attached to a gameObject which is owned by the current client running the application.

gleaming prawn
#

Ask the question you want to ask

runic rose
#

i already asked

gleaming prawn
#

Instead of asking if someone can help you

jade glacier
#

isLocalPlayer in UNET?

gleaming prawn
#

We do help, by answering technical programming questions

fresh frost
#

@stray scroll okay thanks alot

jade glacier
#

UNET/Mirror require players to have an "avatar", and all Commands have to come from that.

gleaming prawn
#

can someone help me about !islocalplayer???
Yes, just ask the question...:)

jade glacier
#

LocalPlayer is the netid that is designated as that object

#

For Unet/Mirror questions you should hit up the Mirror discord... everyone in there uses it so you will get a lot more answers about how things work in those systems than you will here.

#

Few people in here actually use either, but many of us have enough experience with them to give basic advice on it is all.

#

AND... as with all networking. Do the tutorials first.. then ask your questions.

wet portal
#

Hey 👋
I'm really struggling with getting networking in my head, can I get a quick yes/no if my approach makes sense 😅 :
game instance on my android running as a host (with mirror), second game instance as html5 on itch running as a client
essentially only the host needs the app installed

jade glacier
#

Not sure what the question is in there? @wet portal

#

You are building out unity as a web player and want to know if Mirror works for that? I would assume that depends on which transport, but that is something you should ask them in their channel - they will know the transport options better.

wet portal
#

sorry explained it badly. Say I make a game, install it on my android. Then I build it for web and host it somewhere where people host stuff. Will networking work between those game instances?

#

I imagine the answer is general but for extra info I was gonna go with mirror

#

it just sounds like no question cause the question is so basic I think 😁

jade glacier
#

you mean will it work cross platform then?

#

yes, it should

wet portal
#

perfect, thanks @jade glacier 🙂 Just needed a confirmation cause I'm never sure with networking

jade glacier
#

Are you in their discord?

#

its going to depend on the transport if it can work with web players

wet portal
#

the docs mention webgl among others

#

things make a bit more sense now, thanks ☺️

frank edge
#

Hey, i need help with Photon Unity.
I'm making a 2d game, with multiple cameras, but i dont know how to make camera follow for Photon. (1player / 1 camera)

high night
#

@frank edge You should check for ownership in character,
If the character is the owner, then you find the camera.main in character and make it follow the character

#

Just like you'd do player control with owned character

spring crane
#

@jade glacier Plugin based player has not been a thing for a while now, just to be clear. Web techs are now used.
@wet portal Mirror ships with websockets (among others) and there are few ".io games" using it.

jade glacier
#

Not sure what that is in reference to @spring crane

spring crane
#

You are building out unity as a web player
Plugin based solution was called "Unity Web Player". Some people still think that Unity web support == plugin player.

jade glacier
#

Ah

#

Was just referring to any browser based build - no clue the mechanisms they use for that now.

spring crane
#

Yea Unity screwed up by calling it that 😄

jade glacier
#

HTML5 I would just expect they have their own wrapper now

#

That wrapper whatever it is being the player in this context.

spring crane
#

Yea currently runs on WebGL and Web Assembly

jade glacier
#

Good to know

weak plinth
#

Hi there. I read that UNet is deprecated and won't be supported in future anymore. I read through the Deprecation FAQ, but there was nothing written about any current alternatives to UNet.

I would like to start creating a multiplayer game but I'm not sure if it's even worth starting it right now. The new dedicated-server multiplayer feature by Unity is apparently still in work, so the only offical option is using UNet.

Should I start the project using UNet or are there any good current alternatives to it?
https://support.unity3d.com/hc/en-us/articles/360001252086-UNet-Deprecation-FAQ

#

Please ping me when replying. 🙂

#

Mirror?

#

oooh

#

nice, thanks!

#

will this allow to, sort of, "upgrade" to the new multiplayer feature of Unity as soon as it has been released?

#

okay :/

#

aight, thanks, I'll have a look at it

jade glacier
#

Nope. Any of the heavily tied to Monobehaviour libraries are going to make the jump to ECS.

rich flame
#

hello, im using photon and i was wondering why its telling me errors about client being on name server and ready

stiff ridge
#

@rich flame : If you run into errors, it makes sense to try to read them carefully. Anything inexplicable can be copy and pasted from the console, so we get the exact error.

#

Else we have to guess what's up in the first place...

rich flame
#

oh ok ill paste the error

#

i guess i cant copy paste so ill just grab a screenshot, this is the unity window, it still works just the errors annoy me

gleaming prawn
#

You can copy and paste the full error

#

From the bottom tab you have the full text

#

A screenshot is not a lot of help... The full error will show the stack trace

#

BUT, the error is clear:

  • you are trying to call Join room before you joined the lobby...
  • the sequence is: connect (name server, authentication, etc) -> connect-to-master-server -> [optional] join lobby (list rooms, also on master server) -> create/join rooms
#

Please review your code, probably you missed a couple of steps from a tutorial.

rich flame
#

oh ok i didnt realise i could copy from there

#

do you want a pastebin for both the scripts

#

so heres the error JoinRandomRoom failed. Client is on NameServer (must be Master Server for matchmaking) and ready. Wait for callback: OnJoinedLobby or OnConnectedToMaster.
UnityEngine.Debug:LogError(Object)
Photon.Pun.PhotonNetwork:JoinRandomRoom(Hashtable, Byte, MatchmakingMode, TypedLobby, String, String[]) (at Assets/Photon/PhotonUnityNetworking/Code/PhotonNetwork.cs:1588)
Photon.Pun.PhotonNetwork:JoinRandomRoom() (at Assets/Photon/PhotonUnityNetworking/Code/PhotonNetwork.cs:1522)
Lobby:Update() (at Assets/Lobby.cs:51)

#

heres a link for the lobby script

#

can joinRandomRoom be used with connectUsingSettings?

jade glacier
#

You can start with the prototyping components, and just modify those later if you just want to get going.

robust otter
#

Ok so i have just started using Photon as is seemed to fit my needs. The photon server is pc hosted and I want the game to be hosted by players (like minecraft and games alike) Is there a way that i can change the ip that I am joining using code? like, Input ip 127.0.0.1 and connect?

jade glacier
#

Just Photon Server you are using? Not PUN2 or Bolt or any higher API?

robust otter
#

PUN2

#

the PhotonNetwork.Server is get only

jade glacier
#

So you installed PhotonServer and you are trying to run PUN2 with your own Server instance?

robust otter
#

yes the photon server jdk

#

its all setup

#

I just want to know if theres a way to change Server

jade glacier
#

Not sure how PUN2 interacts with that, that might be more a @stiff ridge question

robust otter
#

@stiff ridge Ok so i have just started using Photon as is seemed to fit my needs. The photon server is pc hosted and I want the game to be hosted by players (like minecraft and games alike) Is there a way that i can change the ip that I am joining using code? like, Input ip 127.0.0.1 and connect?

#

How do i set Server

jade glacier
robust otter
#

yes

#

is there a way to set that

jade glacier
#

by setting it?

robust otter
#

using code

jade glacier
#

I'm sure, don't know off the top of my head though.

#

You could just see where that field connects to since Tobi isn't around. I'm sure it's in the docs somewhere but I usually just trace the code from settings to see where things lead.

robust otter
#

can you send a link to the docs?

jade glacier
#

I just google the things I am looking for. I don't actually ever open the API reference or other docs directly.

robust otter
#

oh ok

#

thanks

rich flame
#

sorry i was in the shower but thanks @jade glacier ill try that, might also just check the tutorials but ty

robust otter
#

@jade glacier so I found something called connecttomaster which allows me to put in peramiters

jade glacier
#

Sounds right

stiff ridge
rain surge
#

what does this error mean

#

JoinRandomRoom failed. Client is on MasterServer (must be Master Server for matchmaking) but not ready for operations (State: Authenticating). Wait for callback: OnJoinedLobby or OnConnectedToMaster.

#

i just want the player to connect to a server

jade glacier
#

Kind of what it says, you are trying to JoinRandomRoom but you aren't first connected to the master.

#

Are you using these components? If not use those, or borrow the code in them as the start of your own. You can also extend the OnJoinedInstantiate component and override its behaviors rather than making your own from scratch.

#

@rain surge

rain surge
#

this is my script

using Photon.Pun;
using UnityEngine;

public class LobbyController : MonoBehaviourPunCallbacks
{
    public int SceneIndex;

    public override void OnEnable()
    {
        PhotonNetwork.AddCallbackTarget(this);
    }

    public override void OnDisable()
    {
        PhotonNetwork.RemoveCallbackTarget(this);
    }

    public override void OnJoinedRoom()
    {
        StartGame();
    }

    void StartGame()
    {
        if (PhotonNetwork.IsMasterClient)
        {
            Debug.Log("Starting Game");
            PhotonNetwork.LoadLevel(SceneIndex);
        }
    }
}
#

sorry for late response

#

this should just load the scene right?

jade glacier
#

You aren't first connecting to the main server though

#

I would again, start with the boilerplate prototyping code and modify that.

#

ConnectAndJoinRandom has the startup code pretty stripped down so you can see the steps. You won't guess this stuff really, you have to follow the tutorials or use the templates.

#
{
   Debug.Log("Region: " + PhotonNetwork.CloudRegion);
}```

Did you intend to call like ``PhotonNetwork.JoinRandomRoom();`` in there?
#

You connect to master, but you don't tell it to do anything in response to that.

rain surge
#

yes

#

it works now

robust otter
#

I am making the simple connection to my PC hosted server ```
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using Photon.Pun;

public class NetworkController : MonoBehaviourPunCallbacks
{
//Variables
public string IpAddress = "127.0.0.1";

// Start is called before the first frame update
void Start()
{
    PhotonNetwork.ConnectToMaster(IpAddress, 5055, null);
}

public override void OnConnected()
{
    Debug.Log("connected to server!" + PhotonNetwork.CountOfPlayers);
}


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

}

#

but for somereason the OnConnectedtoMaster is not working

#

OnConnected is supposed to be OnConnectedToMaster I was just testing

#

Nvm I got it fixed. it was just I messed the ip things up

weak plinth
#

is there a easy solution for adding multiplayer in an existing unity project, which has been going on for a while?

#

or does it more like require designing it for multiplayer from the ground up

jade glacier
#

The typical answer is you do not want to add networking after the fact, especially if you have never done networking. Networking is all about producing a tick based simulation that is conducive to being reduced to inputs/states.

#

If the game is insanely simple you can probably tackle it. But I would make a basic networked game before even trying something real regardless.

weak plinth
#

ty

high night
#

You could probably sync the most complicated stuff with RTS networking though right?
running in the past i mean and with deterministic sync (only tranfering inputs over network)

#

.
If you don't use physics and switch to integer math,
and if you are okay with input latency over network,
and also if players don't join an already started game,
i believe it could be very possible to convert an already made game into multiplayer

cedar pond
#

Anyone recommends using either Photon PUN or something else for networking to make quick prototypes and test stuff?

#

I've been running into issues on how to manage the movement and network things with photon doing it from scratch or maybe some assets I could get to prototype with and such?

jade glacier
#

you are welcome to play with the PUN2 beta stuff that I am working on that does a lot of it for you.

cedar pond
#

@jade glacier I bought a character movement from asset store but turns out it isnt made for PUN 2 there are some other ones but not sure if I should get it, just not sure if I can even manage the PUN stuff tbh

jade glacier
#

Depending on how badly it cooperates with FixedUpdate, it should actually be workable.

cedar pond
#

Idk if its allowed to mention asset stuff names here and such mind if I DM you the name of it ?

jade glacier
#

The tutorial somewhat covers how you would convert it to a player object, and you tell a component which controllers should only be active on the owner.

#

you can of course

#

KCC sent me a code so I could test his asset with it, but I haven't gotten to it yet.

#

(Kinematic Character Controller)

#

Unity takes 30% of asset store sales, so they have NO problem with people talking about assets here 🙂

cedar pond
#

Ah, alright

#

But the scripts are pretty complex and I wanted to whip something quick together to present as prototype and showcase 2 player working, I got a basic movement working and Cinemachine camera but it doesnt work like I want it to tbh

jade glacier
#

I've seen that one before, one of my users was using that. It has some pretty heavy use of more advanced animator features, but I think he was able to get it working with the syncAnimator

#

I don't know anything about that second asset, so can't comment on the quality of that code or how interoperable it is with other things.

cedar pond
#

Can you tell me more about the SNS thing?

jade glacier
#

Just that its an extension library for PUN2. I would pretty much just be cutting and pasting text from the Overview in the documentation.

#

The Opsive stuff does a lot of similar stuff, so I wouldn't try to mix the two.

cedar pond
#

@jade glacier I am and my group planning to make a multiplayer fps, do you recommend going PUN route or even using the SNS since its in beta or it doesnt affect like releasing the game on steam or such

#

Sorry if the questions are dumb, pretty new to all of this

jade glacier
#

If its a competitive FPS, I would recommend Bolt typically. Is this a project with funding, or just for your own fun?

#

Doing server auth yourself without any networking experience can turn into 2 years of learning.

cedar pond
#

If its a competitive FPS, I would recommend Bolt typically. Is this a project with funding, or just for your own fun?
Currently it is just us working on it as a project for uni, and out of pocket to release (required to release to pass)

#

Doing server auth yourself without any networking experience can turn into 2 years of learning.
ouch

#

Would you recommend for beginner like me and my group to maybe go single player/split screen route then 😅

jade glacier
#

If you are new to networking, I would not try to make a real game until you have made a few fake tutorial-like games.

cedar pond
#

If you are new to networking, I would not try to make a real game until you have made a few fake tutorial-like games.
Sorry, didnt understand

jade glacier
#

Learn to network first, then start work on your game.

#

Don't try to learn to make a multiplayer game with a project you intend to finish. It will take 20X longer than you think, and you will hate the game by the end after you have refactored and restarted 20 times.

cedar pond
#

So we should maybe divert into singleplayer/split screen game rather than network (and while with that in the background myself learn networking stuff)

jade glacier
#

Until you know the vocabulary of networking you are going to make all the same mistakes everyone makes when starting.

#

I can't answer that. I am just saying that you will not just "network your game" nearly as fast as you think.

#

especially if you are learning the whole paradigm of online multiplayer and the architectures needed to make it work.

cedar pond
#

Hmhm, I mean I havent slept and been trying to make a simple move 2 players work for the past 1 and half days and it still has a million bugs

#

And we are also required to "release" the game to pass 😅

jade glacier
#

yeah, everyone can get two players moving in about 20 minutes.... its easy to get started and feel like you are making progress

cedar pond
#

yeah, everyone can get two players moving in about 20 minutes.... its easy to get started and feel like you are making progress
Thing is I am struggling with that already so I guess thats why I am trying to latch to asset store stuff and make something work but maybe I should drop it

jade glacier
#

the issue is when the race conditions start to pile up, and you see what latency/loss/out of order packets do to your whole system... you get buried in the details of why the quick and easy ways don't cut it.

#

You can try the CC asset and see how their built in networking translates into a working game.

#

I have no idea what kind of networking they have going on behind the scenes, so I can't comment on if it will turn into a race condition hellscape, or if its solid.

cedar pond
#

Hmm I see

jade glacier
#

I would start by doing tutorials for a handful of the libraries.

#

Bolt, Mirror, PUN2, SNS, Forge and whatever else you find.

cedar pond
#

Thing is we are required to make a game and push it and make profit (even if its low amount) within 20 weeks 😅

#

I think promising multiplayer was a mistake

jade glacier
#

yeah, multiplayer in 20 weeks is not something even as a dedicated MP dev I would want to be promising, unless that game is super simplistic.

#

It took me 2 years to get solid with creating a good state transfer interpolated system, and a lot of restarts and refactors. For that kind of timeline you will want to pay for a full stack like Quantum or Bolt. Or go let them know that a MP game in that timeframe is not recommended.

#

MP games have a whole other layer of complexity on the marketing side... since you aren't selling content - you need players to populate your servers, so players are the content.

#

I wouldn't even talk to anyone about networking until you have some small working MP games you built on a couple of the libraries.

#

You need to start to learn the vocabulary before you can even ask the right questions.

cedar pond
#

I see, thing is they put me in charge for MP in this project game and I am worried if I come forward letting everyone down it will mean everyone getting an F or something because we had to pitch what we will be making and so forth

#

You need to start to learn the vocabulary before you can even ask the right questions.
Hmhm, sorry if I am asking dumb ass questions

jade glacier
#

better to correct their expectations as soon as possible.

#

What the hell company are you working for that would even float a profitable MP game in 20 weeks as being a thing?

cedar pond
#

It isnt a company per say, its a "gamelab" project where we are a company and we got 20 weeks to make something and release it and profit, we put multiplayer on it since we thought it will be good selling point but that is going to bite us in the ass I see.

#

Since you can get a green light on your own custom idea or you get a pre defined serious game concept to make (which are all shit) 😅

#

better to correct their expectations as soon as possible.
@jade glacier We do have a coaching session tomorrow morning and I will be brining the news to drop MP all together but idk if that means they will fail us or how it is going to tbh

#

We were told to scope down on our concept but idk if dropping MP is considered scoping down and if we drop MP we also need to edit the concept since it was a pvp shooter, not sure how they will take that tbh let alone me telling my group not possible

jade glacier
#

I wouldn't go into MP for profit without REALLY knowing the landscape.

cedar pond
#

Yeah from everything you told me so far, I am 100% dropping MP

jade glacier
#

I don't even know that landscape. Its a whole different sales proposition, and has a whole different cost structure.

#

I would play with networking if it interests you. But I would avoid commitments surrounding it until you have some experience on your own.

cedar pond
#

I dont really know how the "real" world of game dev works but the coaches are acting as "investors" so idk if it is alright of us to go them and say we changing our whole concept we got approved on (not fully, still keeping some elements we had from previous one) but also dropping MP, not sure if a real investor would say wtf and kick you out 😅 since if they say that i dont have the expereince to say "no" and counter argue or such

#

I would play with networking if it interests you. But I would avoid commitments surrounding it until you have some experience on your own.
@jade glacier Yeah that is what im planning to do after everything you've told me ^^

jade glacier
#

Good. Don't let me discourage you from getting into net dev. It's fun, interesting and challenging. Just not something I would want to be learning under the gun.

cedar pond
#

Good. Don't let me discourage you from getting into net dev. It's fun, interesting and challenging. Just not something I would want to be learning under the gun.
@jade glacier Oh nono, sorry I didnt mean it like that, I am super interested and will be taking it in the backend while working on this project just not actually develop it for something to release in 20 weeks

solid crow
#

okay so i'm missing something- are RPCs and RaiseEvent intended to essentially call a function across all clients?

jade glacier
#

Raise event sends a message to others through the relay

#

RPCs use raise event to send messages that simulates a remote function call.

ashen canopy
#

hey is anyone online now? I have some networking problems

stable epoch
#

Im having an error with Photon Pun2 RPC Function:

Illegal view ID:0 method: RPC_AddCharacter GO:PlayerCharacter(Clone)

PhotonView with ID 0 has no (non-static) method "RPC_AddCharacter" marked with the PunRPC or @PunRPC(JS) property! Args: Int32

stiff ridge
#

@ashen canopy : In doubt, just ask. If nobody replies, you can update us on any progress.

#

@stable epoch : That looks as if you try to call the view.RPC() on an object that's not network instantiated?

#

Use PhotonNetwork.Instantiate() or load the object with the photonView with the scene.

#

Either will set a viewID for it that's non-0.

stable epoch
#

That looks as if you try to call the view.RPC() on an object that's not network instantiated?
@stiff ridge
How do i network instantiate something?

stiff ridge
#

PhotonNetwork.Instantiate does it.

chrome rover
#

Hello

#

Someone have tutorial for networking

#

Database query

narrow oriole
#

I am pretty sure Google has

chrome rover
#

well it is a little confused

robust otter
#

what is this error? Assets\FPSPhoton\Scripts\NetworkController.cs(3,14): error CS0234: The type or namespace name 'Pun' does not exist in the namespace 'Photon' (are you missing an assembly reference?)

#

im new to photon

jade glacier
#

FPSPhoton isn't Photon. Did you buy some 3rd party asset/

robust otter
#

No I just made that file

#

do i need to move it to assets?

#

it was working fine the other day

jade glacier
#

No idea. Does it not show errors in VS of not being able to find PUN?

robust otter
#

nope

#

I can send the code of the C#

#

but i tried making a new C# file and It sill wasn't able to be added to an object

#
using UnityEngine;
using UnityEngine.UI;
using Photon.Pun;
using System.IO;

public class NetworkController : MonoBehaviourPunCallbacks
{
    //Variables
    public string IpAddress;
    public string Name;
    public string NoName = "";
    public GameObject EnterIP;
    public GameObject EnterName;

    public GameObject StartMenu;
    
    
    void Start()
    {
        
    }

    //check if Ip entered is valid
    public void JoinPressed()
    {
        IpAddress = EnterIP.GetComponent<Text>().text;
        Name = EnterName.GetComponent<Text>().text;
        if (!string.IsNullOrEmpty(EnterName.GetComponent<Text>().text))
        {
            Connection();
            RPC_CreatePlayer();
        }
    }

    //join the local game
    public void JoinLocal()
    {
        IpAddress = "127.0.0.1";
        Name = EnterName.GetComponent<Text>().text;
        if (!string.IsNullOrEmpty(EnterName.GetComponent<Text>().text))
        {
            Connection();
            RPC_CreatePlayer();
        }
    }
    //Connection
    public override void OnConnectedToMaster()
    {
        Debug.Log("connected to server! " + IpAddress + " | " + PhotonNetwork.CountOfPlayers + " players " + "| Name = " + Name);
        StartMenu.SetActive(false);
        PhotonNetwork.AutomaticallySyncScene = true;

    }
    //addplayer
    private void RPC_CreatePlayer()
    {
        float randomValue = Random.Range(0f, 10f);
        PhotonNetwork.Instantiate(Path.Combine("Prefabs", "PhotonCube"), Vector3.up * randomValue, Quaternion.identity, 0);
    }

    private void Connection()
    {
        PhotonNetwork.ConnectToMaster(IpAddress, 5055, null);
        PhotonNetwork.LoadLevel(0);
        
    }
    

    void Update()
    {
        
    }
}
#

iv made most the code from scratch

jade glacier
#

None of that code gets red underlines in VS?

robust otter
#

no

#

I think the project is messed

jade glacier
#

Restart everything maybe. If VS is happy with it and Unity isn't might need to toss your library folder and such.

#

Restarted Unity?

robust otter
#

Nope i will do that now

#

Ill check if maybe the scenes are causing it too

#

name error is there

#

theres lots of errors

#
Assets\Photon\PhotonRealtime\Code\LoadBalancingClient.cs(3435,77): error CS0535: 'ConnectionCallbacksContainer' does not implement interface member 'IConnectionCallbacks.CreatePlayer()'```
#
Assets\Photon\PhotonRealtime\Code\SupportLogger.cs(45,46): error CS0535: 'SupportLogger' does not implement interface member 'IConnectionCallbacks.CreatePlayer()'```
#
 
Assets\FPSPhoton\Scripts\NetworkController.cs(3,14): error CS0234: The type or namespace name 'Pun' does not exist in the namespace 'Photon' (are you missing an assembly reference?)```
#

Any idea now?

jade glacier
#

If you start with a fresh install and the latest PUN2 do you have any errors like that?

robust otter
#

I think I will try this when i get back home today

#

for now I think i will take a break

#

deal with it later

jade glacier
#

Go back to a git state when you didn't have these problems

robust otter
#

what is a git state

jade glacier
#

Are you using git?

robust otter
#

no

#

Idk what git is Github?

jade glacier
#

or any of those

robust otter
#

No ive never made backup of the project

#

noob move ik

#

It was working before i went to bed last night

jade glacier
#

comment out all of your code and see if PUN2 by itself is giving any errors

#

And slowly readd your code.

robust otter
#

there was one error before i went to sleep last night and all it was is i put a prefab in a wrong folder

#

yeah im going to get off and deal with this later

#

I have to go

stray scroll
#

Hmm, this is most likely just a NetCode thing, but their code currently on send buffers X amount of previous input commands. Currently my input is setup so I send e.g. if I trigger a button press, which is not the same as holding down the button. So currently only one trigger/command. Soo.. if the framerate is trash, like it is in the editor, so the client doesn't have framerate enough to produce input for all serverTicks, it will copy the closest older tick when generating send buffer. So.. this causes in editor for me when I click once, to click 3 times. So any ideas if I'm thinking about this in the wrong way? Would rather not go in and change their code.

I know I could A

  • Fill up the empty input spots on my own until the tick I'm generating input for, to make sure no trigger input is added there.
    Or B
  • Add generated tick to the input data, which I can check vs on server side to disable "trigger input".
robust otter
#

For Photon if i make a master server and dont add any rooms does that mean the master server is one big room and i dont have to do and room things?

jade glacier
#

Master server is just there for matchmaking pretty much.

robust otter
#

ok so i dont have to do the match making tho?

#

cuz my game is just join a ip

jade glacier
#

I don't know it all that well, but I would expect there to be things you can do while connected to the MasterServer to indicate what kind of room you want to join. But out of my wheelhouse. I would need to read the docs and do the tutorials.

#

You are hosting your own server you mean?

robust otter
#

yes

jade glacier
#

Even with that, the master server is probably different from rooms.

#

Rooms are the actual game.

#

Master server is there to find players to put into the game instances.

robust otter
#

ok

jade glacier
#

Using JUST server and not PUN2 though I have no idea what the usually architecture is, if any.

#

Connecting to the Master you don't have any awareness of other players and such... its just you and the master working out which room to put you into.

#

So you aren't going to be doing any "game" stuff there.

robust otter
#

what does this mean? JoinOrCreateRoom failed. Client is on MasterServer (must be Master Server for matchmaking)but not ready for operations (State: ConnectingToGameserver). Wait for callback: OnJoinedLobby or OnConnectedToMaster.

jade glacier
#

Where are people getting their sample code lately? This keeps coming up.

robust otter
#

oh i can send the vid im watching

#

but yeah do you know how i can fix it

#
 public void CreateRoom()
    {
        if (!PhotonNetwork.IsConnected)
            return;
       
        //Join or create room
        RoomOptions Options = new RoomOptions();
        Options.MaxPlayers = 10;
        PhotonNetwork.JoinOrCreateRoom(_roomName, Options, TypedLobby.Default);
    }

    //room callbacks
    public override void OnCreatedRoom()
    {
        Debug.Log("room created");
    }
    public override void OnCreateRoomFailed(short returnCode, string message)
    {
        Debug.Log("failed to create room?");
    }
    public override void OnJoinedRoom()
    {
        Debug.Log("joined room!");
    }
    public override void OnJoinRandomFailed(short returnCode, string message)
    {
        Debug.Log("Join room Failed! " + message);
    }```
jade glacier
#

Where are you calling created room though?

#

That should be inside a connected to master callback

robust otter
#

it should be inside? of onconnectedtomaster?

#

How does join or create room work anyways

jade glacier
#

It has to happen somewhere after you connect to master

#

Just use the prototyping components

robust otter
#

I wish there was a photon series for my need

#

because i have to piece all the code together and most of the time it doesn't work

jade glacier
#

I would start with the prototyping components, and expand on those

robust otter
#

ok

#

wait

#

so i dont know if this works

#

but what im trying to do is make it so i can join differant ips that other people are running

#

so ive made a input ip field and all that

jade glacier
#

That sounds not pun at all

robust otter
#

yeah

jade glacier
#

Pun is relay, players don't host. One player in each room will be designated as master client, but they are not a server, and players don't connect to one another

robust otter
#

is there a way that i could do this tho

#

if not its fine with me but

#

im just messing around

#

I need to know if theres a way to make servers like minecraft has done them

#

player hosted and all

spring crane
#

Just use some networking solution built for that sort of setup

robust otter
#

do you know any ive been looking around and couldn't find so i tried photon

jade glacier
#

If you want players to act as actual servers you need something other than pun.

spring crane
#

Mirror, MLAPI, Forge Networking, some other Photon products, DarkRift... 😄

jade glacier
#

Pun avoids having to deal with punchthrough and host migration by doing away with both. Which has benefits and shortcomings

spring crane
#

Most networking solutions are classic dedicated server setups

robust otter
#

ok thanks i will check out all of these

#

is there a recommended one out of all of them though?

jade glacier
#

Any option that allows a client to host usually has some punchthrough scheme available for free if you host or for charge of not.

robust otter
#

yeah minecraft has that problem but idc

#

the games for me and my friends at the moment

#

and there's no point making huge dedicated servers at the moment

spring crane
#

Mirror has very active community and API is very similar to UNet

jade glacier
#

Noble whale sells a nat punch asset for it.

robust otter
#

I think im going to try mirror seems pretty cool and not to complicated as it is based of of unet

jade glacier
#

It's just a messaging layer, like pun is. So you'll have to do a fair amount of work yourself. Be sure to join their discord.

spring crane
#

It's no longer tied to UNet in any way, just inherits similar API

#

They are trying to keep close to drop in replacement for projects that used HLAPI Community Edition, which was then dropped in favor of making something completely new

jade glacier
#

They have long departed from drop-in replacement. I've had to support them with my asset for a couple years, and there have been a lot of breaking changes from UNET

robust otter
#

is hlapi any good too

#

because it seems interesting

#

the movment is perfectly synced

#

is it viable to use for a fps

#

?

jade glacier
#

They are messaging layers. So you are on your own for proper syncing.

robust otter
#

and anything special about forge networking

jade glacier
#

I sell assets for syncing transforms and animators because the networking libs are pretty bad at that with their sample components.

#

Forge is a slightly different wrapper, but it's still a messaging layer with meet object identification.

#

Bolt is your only full stack option for fps.

robust otter
#

photon bolt?

#

but then i run into the same problem of no player hosting

#

so i guess i have to make do with the other options

weak plinth
spring crane
#

@robust otter If HLAPI were any good, they wouldn't have created Community Edition of it and then given up on it 😛

#

@jade glacier That might be, but that was more in a way that tutorials are very interchangeable

#

I imagine some of the breaking changes are covered by their updater though.

faint mural
#

@weak plinth can you use nodejs on mobile devices or for LAN gaming in general considering no player has nodejs preinstalled?

weak plinth
#

Only the server is node js, so in a lan setting you would need a server that could run node or use your dedicated server. In terms of this technique is only doesnt really work with the WebGL

faint mural
#

WebGL or when you are LAN gaming with none of the devices have nodejs installed. I know about the dedicated server setup. Basically if you are targeting a game which is multiplayer connecting to a dedicated server/player machine with nodejs, node js is your way to go.

weak plinth
#

Your clients wont need node js though so you should be okay

faint mural
#

Yup. This is why I had to go for pure C# way to implement networking for a mobile game setup.

#

For testing I used a machine with nodejs installed but later on I had to reimplement things with C#.

#

It was a local game setup over wifi

weak plinth
#

Yeah this is trying to replicate what you would see in a AAA environment for a game where you just connect, find a match/room and go. Mobile sample is something like Clash Royale where all the clients connect via mobile devices to a hosted node js server on like AWS for example.

frank edge
#

Hey guys, how can i make different spriterenderer colors/different players in unity photon pun?

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

public class Player_Color : MonoBehaviourPunCallbacks
{
    public static int number_of_players;
    public float number_of_p;
    private SpriteRenderer sprite_render;

    public Color Blue;
    public Color Red;
    public Color Green;
    public Color Pink;
    public Color Light_Blue;
    public Color Light_Red;
    public Color Light_Green;
    public Color Light_Pink;

    private void Start()
    {
        sprite_render = gameObject.GetComponent<SpriteRenderer>();
        number_of_players = PhotonNetwork.CountOfPlayers;

        if (number_of_players == 1)
        sprite_render.color = Blue;

        if (number_of_players == 2)
        sprite_render.color = Red;

        if (number_of_players == 3)
        sprite_render.color = Green;
    }
    private void Update()
    {
        number_of_p = number_of_players;
    }
    public void OnPhotonSerializeView(PhotonStream stream, PhotonMessageInfo info)
    {
        if (stream.IsWriting)
        {
            stream.SendNext(sprite_render.color);
        }
        else
        {
            sprite_render.color = (Color)stream.ReceiveNext();
        }
    }
}

#

i made this code, but it doesnt works

gloomy meteor
#

hi

#

here's the code

narrow oriole
#

You want us to fix it for you? @gloomy meteor

gloomy meteor
#

no i just need to know what i am doing wrong

#

why the rpc is not being called

narrow oriole
#

Basically to fix it for you

frank edge
#

place a transform view and etc to your gun too @gloomy meteor

gloomy meteor
#

@frank edge ok let me try that

frank edge
#

at inspector

#

lol

gloomy meteor
#

i am sorry i dont get it i am actually very new to unity

#

hey?

faint mural
#

In the inspector as component
(PS: I dunno the whole case)

gloomy meteor
#

oh i get it now

gloomy meteor
#

hey i still need help

#

anyone who can help me?

#

the rpc isnt being called i guess?

burnt axle
#

Seems like the issue is game logic related since the RPC obviously works.

gloomy meteor
#

yea i guess so

#

the gun is being equipped locally so i guess the equip method is just fine

#

but it is not being shown to others

burnt axle
#

You dont need to pm about the issue, its better to let others know about it here so others can benefit from similar problems.

gloomy meteor
#

sorry

burnt axle
#

And if you want others to look at your code you need to paste the whole code.

gloomy meteor
#

ok lemme do that real quick

burnt axle
#

Its okay, just letting you know how it works around here 🙂

gloomy meteor
burnt axle
#

Do remote clients have access to the prefabs (or just gameobjects) like the local client has?

gloomy meteor
#

they have access to the the whole player character including the guns(prefabs)

#

both players can equip the gun locally

#

they can shoot each other as well

#

and even bullet holes can be seen just not the guns

#

you checked my code?

burnt axle
#

The PunRPC method looks fine, if you are able to see other bullet holes (i assume this are PunRPC too) then the issue is within the specific eguip method.

gloomy meteor
#

yea dude i am kind of stucked here

#

but i guess even the equip is working fine when i am able to equip the gun locally

burnt axle
#

What does this line do: t_newEquipment.GetComponent<Sway>().ismine = photonView.IsMine;?

gloomy meteor
#

oh thats for the weapon sway

burnt axle
#

That doesn't say me anything

gloomy meteor
#

its for only showing sway if the user is using the gun

#

you want me to remove that and try again?

burnt axle
#

Nah, try to change the gun prefab with something else and see if that works

gloomy meteor
#

ok

#

bro

#

if i have set local position to set the correct position of the gun does that mean that only i can see the gun at that position?

robust otter
#

So I need to instantiate a prefab as the child of the object that is calling the instantiate using mirror

#

how do i do this

#

I have made the instantiate work but it does not spawn as child

weak plinth
#

Um, im new, i want to make a lan/online server game like minecraft or terraria. Do i need to know socket programming for that?

robust otter
#

no

#

at the moment im learning mirror

#

its a replacement for unet

#

which is now depricated

#

@weak plinth I recemend Photon https://www.photonengine.com/en-us/Photon
or mirror https://assetstore.unity.com/packages/tools/network/mirror-129321
as for mirror here is a good series to follow: https://www.youtube.com/watch?v=zSTubohQcvE&list=PLkx8oFug638oBYF5EOwsSS-gOVBXj1dkP&index=1
If you are completely new learn to make singleplayer games first so you can know the basics of c# and unity.

Mirror is a high level Networking API for Unity, built on top of the low level Telepathy library.
( Forum )
( Discord ) ( Docs ) ( Sponsors )

Mirror is built and tested for MMO Scale Networking by the developers of uMMORPG , uSurvival and Cubica .

Mirror...

#

if you want to spend money for servers and stuff use Photon
if you want to host the servers use mirror

#

both good

buoyant stag
#

I heard that MLAPI is a much more better alternative than the Mirror

robust otter
#

Is there a reason?

#

@buoyant stag why is it better I need to know because i just started using mirror and if I should switch over

buoyant stag
robust otter
#

Thanks will check out

weak plinth
#

Thank you

gleaming prawn
#

Just one remark: using mirror or mlapi, or any "free" solution you will also spend money on servers (you need to host them somewhere, unless you are just doing a LAN game). And these are not exactly cheap... Specially when a single machine can barely run a poorly designed server...

weak plinth
#

why not cheap? I've hosted 40 players on https://www.hetzner.com/cloud with the 2 vCPU option, but it was with the old bolt 0.4.3.1 i think and its understatement to say its better coded then mirror one or mlapi, etc..

#

also i think the main feature of bolt is more productivity then performance, you can setup a game in a weekend in bolt but it will take you 2weeks - 1month with most other networks to create the same experience

#

not even mentioning a real game

gleaming prawn
#

I'm not advertising bolt in itself... It also requires you to host the servers...

#

I'm saying the person said in photon you pay for servers, as if you would not pay in other solutions. You always pay.

#

And 40 players in one machine? A single self hosted photon server can host thousands of players, so it really depends on how efficient you can make your server logic.
I just question that common belief that paid solutions are expensive... Many times they are cheaper than you think.

spring crane
#

@buoyant stag That post recently became 1 year old. While some of the stull still holds true, a lot of the sillier performance things have been addressed afaik

#

My primary problem with MLAPI is that while it seems better and more mature in practically every way, it lacks the community support and thus I'm always wondering if I'm the first person to do something with it in production.

#

Sort of "known bad" situation

buoyant stag
#

@spring crane I'm not sure that the Mirror changed it's paradigm :c
Even if it works better than before, I think that stuck with tool which have a strange direction is a bad idea.

#

Sort of "known bad" situation
@spring crane I understand.
Did you contact with developer?

spring crane
#

Contact who?

buoyant stag
#

@spring crane with TwoTen

#

I think he'll be able to help you

#

I didn't work with MLAPI yet, but I have my own tool and I helping people who contact with me by email

#

I think most developers do it also

spring crane
#

I'm trying to avoid the situation where I have to talk with TwoTen or Vis2k. I know games (more importantly, browser games) that have successfully launched with Mirror. I don't know any that have launched with MLAPI.

buoyant stag
#

Even more games were launched with UNET 🙂

spring crane
#

Fair 😄

#

I think the situation with UNet and Mirror is a bit different though

buoyant stag
#

Yes

#

Anyway we need a new wonderful common solution from unity

#

Netcode come to us and be wonderful pls!

faint mural
#

I heard they were doing something along with DOTS

weak plinth
#

looks like there is something new cooking, networks are blooming out this year for some reason

#

doesn't look bad at all, also neat replay system

mint acorn
#

@weak plinth what is game?

high night
#

I am trying to implement rocket league style networking (rollback-resim clientside prediction on all objects with full server authority)
(game is not related to rocket league)

I also want to have voxels on top it
I thought i should exclude the voxel system from this rollback/resim system
It will not regularly sync states, only inputs to this system will be sent out by server
Make it into a different system that runs in the past on clients and never rolls back
(All colliders are static in this system)

You think it's a good idea?

slender bear
#

How would I go about doing multiplayer when a user clicks "play", without having them type in the port/server they want to connect to?

#

Sorry if this question is worded weird, I'm fairly new to this aspect of Unity.

weak plinth
#

Do you mean a quick join feature?

slender bear
#

Yup.

#

Would I need to connect them to a dedicated server?

weak plinth
#

Honestly myself im only a novice

#

but i remember like the default unity server join thingy had somethign like that

#

ill do some research

slender bear
#

Thank you

weak plinth
#

np mna

slender bear
#

It's very difficult to find people in this community willing to help.

weak plinth
#

sorry for my lack of knowledge lol

slender bear
#

I've asked a few people here, and I've been either straight out ignored or neglected.

high night
#

unet matchmaking servers might not be up since unet is deprecated

slender bear
#

It's not matchmaking

#

When you click "play" button on my website, it will launch the downloaded file

#

and you'll be in the game

high night
#

If you want a single dedicated server for now, i guess you could hardcode it's ip/port

slender bear
#

Another issue is

#

Just setting up the dedicated server

high night
#

Just another unity instance? @slender bear

#

It's going to host the game

#

But you should probably do the headless build that excludes graphics stuff

slender bear
#

Hmm

#

What do I need to do the dedicated server?

#

Allow a specific port?

high night
#

That i haven't done yet, i heard port forwarding

slender bear
#

Hmm

#

This is on a VPS, though

#

Never port forwarded via PST

#

VPS*

high night
#

Hmm, i see

slender bear
#

How much experience do you have in Unity Networking?

#

Just curious, lol

high night
#

Just made some incomplete games thats all

#

Haven't set up a dedicated server yet

light elm
#

But you should probably do the headless build that excludes graphics stuff
@high night Have you guys tried the Headless Builder asset?

#

It excludes stuff like graphics, shaders, lighting from headless builds

high night
light elm
#

Yeah, but those builds still contain all textures in the build and in RAM, etc.

#

Which isn't needed

high night
#

oh, and this asset doesn't do that?

light elm
#

No, it strips those assets, and also shaders, etc.

#

People in the reviews are reporting much reduced CPU and RAM usage

high night
#

hmm, i'll check this asset out

slender bear
#

Any tips on sending player movement to the server?

#

How would I go about sending it securely?

jade glacier
#

Secure why?

#

Inputs only naturally is already anti hacker.

slender bear
#

Trying to prevent someone from spoofing other players character position

#

@jade glacier

#

It's currently an issue in my game

#

A kid is spoofing all players off the map

#

And it's ruining the game experience

jade glacier
#

What is your architecture? Clients should only be sending their own inputs to the server.

slender bear
#

Can I forward you my code?

#

It's 10 lines

jade glacier
#

Clients should be unaware of other clients connections

#

Can post it of course

#

Can't promise I can read it, but someone might

spring crane
#

Are you doing player "hosted" stuff right now?

#

Like PUN?

high night
#

Server knows which input comes from which client
You will get a clientside error too if you tried to send inputs or a command from a different players "player object" (authorized object)
(can't send command from unauthorized object or something)
That input will never reach the server
@slender bear

spring crane
#

You could spoof the location on the client for screwing with the hit detection system, but one client shouldn't be able to affect other clients like that

dry pewter
#

hi, quick question, what do you guys think is the ideal method to set up a simple multiplayer game, where theres only 2 - 4 players at a time. i can have under 20 concurrent users, so preferably an option that has that setting as free

#

iv heard of things like photon and unity's unet or mirror

#

any advice on what might be best for my use casE?

tawny hollow
#

Hi there, I was wondering if anyone would know how to change a game object's name on client side and then update that to the server side? I'm using UNet right now but i'm at a loss on how to update it to the server

stray scroll
#

@tawny hollow By Commands, i.e. command attribute. Note that UNET is deprecated.

tawny hollow
#

Is there an alternative due to it being deprecated?

stray scroll
#

Check Photon or Mirror (mirror being Fork of UNET)

dry pewter
#

what are the cons of mirror

tawny hollow
#

Ah, just double checked the documentation on Command and realised I wasn't calling the command in the client's player object

#

This seems to be fixed now, thank you

spring crane
#

Mirror is not fork of UNet

#

Well I guess the high level API is, but my understanding is that most things have been reimplemented by now. UNet's transport layer is not used either.

#

@dry pewter With Mirror you would have to setup your own servers. You also don't get region based stuff out of the box.

stray scroll
#

Is it not? Their storefront says it's based on it, and that's what I've heard people saying, might be wrong I guess.

spring crane
#

PUN is ideal if you don't mind players having a bit too much authority

#

Yea I guess I jumped on the gun a bit too soon with that. I think it technically is fork of UNet, but I don't know how much of actual UNet is left at this point

robust otter
#

@stray scroll just started using mirror and I am loving it for my needs. it was really easy to learn if you already know how to use unity. There are some downsides like having to host the servers yourself. but that's what i wanted in my game so it was fine. yesterday last night i got 4 of my friends to join my game and it was almost flawless, the person hosting the server has almost no impact on performance. If you want the games to be hosted by the players or you are planning on making the servers yourself then go with mirror. ( you can follow almost any unet tutorial but somethings you will have to figure out yourself ) Hope this helps!

#

ps. one of my friends was in the states and im in canada ( not that far but still you get the point on how well it handles players )

#

If your planning on spending money on your game and making it worldwide with matchmaking GO WITH PUN. mirror is ment for player hosted games and lan.

#

Sorry didn't read the rest of the conversation @tawny hollow

spring crane
#

You can do matchmaking stuff with Mirror, but you need to implement that yourself on top of Mirror. Server list solutions are already available.

robust otter
#

Yeah

#

But at that point you might as well use pun

high night
#

It's a bad idea to do snapshot interpolation for a melee fighting game? (like chivalry, mordhau, street fighter, for honor)
Having all other players in the past is an issue i assume

#

What do you think is the best choice of networking for a fighting game as such?

jade glacier
#

streetfighter type games you typically want extrapolation with a lot of resim

#

Or some hybrid if you can swing it

#

For fighting games you are typically working with events, which are deterministic in nature once they occur. Like once you start a move its pretty locked in how that move is going to play out for the next X milliseconds

high night
#

@gaunt socket You'd send full inputs for each frame to server and let the server simulate them all
This way most of the time, servers instance of your character will deterministically end up in same pos
And server sends back the new position of your character

This position the server sent is from the past now. Lets say frameNo == 100 for example
And client sees frameNo == 120

Your client will compare its instances saved position at frameNo == 100 to what server sent
If it's different you'll set your characters position to what server said t frameNo == 100
And simulate with the same inputs you recorded (and sent to server) until frameNo == 120
player won't notice all this

#

I said position but it's not just position you have to these for.
You need to do the same stuff for position, rotation, velocity, angVelocity, health of the player, how many bullet the player has left in magazine, etc etc.
It's the full state of the character

jade glacier
#

Depends on how you architect it. You either let the player predict and exist in the future, and have the server rewind for attacks, and rearrange the world to how the client would have seen it, or you do it with extrapolation (an ideally determinism) and you have the player constantly try to guess the future state of the server so that it lives in the present.

high night
#

@gaunt socket You shouldn't need to do any prediction woth extra logic like that

#

Just shoot the projectile like you do in server without waiting for server response

#

And then send the input to server that says you shoot

#

Server will simulate with same input
And will most likely have the same output

#

You should treat the projectile same as* movement imo

jade glacier
#

I still don't know if you are talking state interpolation, or input extrapolation

high night
#

Me?

#

yes %99.9

#

it may not hit the other player though
if other player moved away at the last milisecond
you still display the blood effects though, theres nothing to do
you get a missregistered hit if that happens
client sees that it hit but on server its not

jade glacier
#

Client prediction typically means extrapolated state transfer. Clients respond to their own player input immediately locally, meaning the player exists in a different timeframe than the server.

#

Rewind is employed on the server in that case to recreate the different world view the player had when they shot

#

One alternative is continuous input extrapolation on clients, where they constantly are guessing the future of unowned objects.

#

This requires a lot of resim on clients, as new player inputs arrive it has to rewind bad guesses and make a better guess

high night
#

^this is whats called "state syncronization" right?

jade glacier
#

State sync just means the sun results are shared. As opposed to player inputs.

#

It's messy extrapolating states, so typically state transfer means interpolation.

#

And deal with the inherent desync with rewind, or client authority.

#

Phone typing, lots of typos here

high night
#

damn fat fongers

jade glacier
#

Just dumb prediction. Google can't predict tech conversations well

#

Interpolated state transfer with client prediction and server rewind is the csgo way... But not the only way.

high night
#

you wanna create a fake projectile?

#

and never display servers one

#

Servers projectile trajectory will be totally same though

#

its totally predictable

jade glacier
#

For projectiles you can talk advantage of their deterministic nature

high night
#

@gaunt socket if projectile shoots in 200ms or something like that, you can work with it

#

but hmm

#

nevermind that

jade glacier
#

In the past with state interesting I would fire them at a slower velocity and some initial delay, then lerp them so the merge with the expected server confirm, then accelerate them to actual speed.

#

Or the reverse if you make them in the players timeframe

high night
jade glacier
#

Just lots of futzing until you find the right compromise for your particular game, and the speed involved

#

It's not the only answer, just one possible one

high night
#

my fast forward was smooth though

jade glacier
#

that would be if with player auth if I remember that post

high night
#

hah this is bad though o need for extra code for extapolating projectiles

jade glacier
#

Same idea as yours, the color change indicates where it is in getting into agreement with the world state

#

yeah, fires immediately but at a slower rate

#

so that it will be partially in agreement with what it is expecting the server to confirm

#

it basically starts slow and then speeds up once it is in agreement with the world state

#

so its basically shifting timeframe from the player, to the world

#

its purely cosmetic regardless

#

the server has the only real projectile

#

you can hide it with a little player side shot latency, if its a slower moving projectile

#

lag compensation is a word I personally avoid, since it implies all kinds of things that may not be meant

#

There are multiple timeframes in play when interpolating... so I just think of which timeframe things are in

#

The player movement is 100% in the players timeframe... the world around the player are all in the server's time frame

high night
#

@jade glacier
if you had hitscan shooting, and had the world view in past, wouldn't that cause issues?

jade glacier
#

You pretty much have to do server rewind for hitscan... or go with client auth

high night
#

players would have to compansate for hits no?

#

oh

#

i see how it is

jade glacier
#

"compensation" is a terrible term... could mean anything

high night
#

ah, i remember the overwatch video now

#

didnt make sense back then

jade glacier
#

CSGO and Photon Bolt rewind the scene on the server so that things are close to how the shooting player saw them, and recreates the shot.

#

vs modern battle royales where the server can't spare that much CPU, my understanding is they give a lot more client authority

#

so the client says they hit someone, the server just does a simple "is that reasonable" test instead of a rewind.

#

If you fire a hitscan instantly as a player, the hitscan you see is in the players timeframe

#

The server if not rewound would say most of your shots missed in that case if it has shot authority....

#

so the two choices are give the client authority... or have the server do a fancy rewind

#

The third alternative is to extrapolate

#

its the most elegant result, but hard as hell to do

#

extrapolate everything

#

other than the player

high night
#

players could maybe extrapolate but only for close proximity

jade glacier
#

you attempt to bring the world into the players timeframe with constant guesses

#

That is how determinstic engines like Quantum deal with latency

#

It is constantly making a guess based on players past inputs and it resimulates every time it gets new more current info

#

So its constantly lerping between guesses

#

fighting games tend to extrapolate yeah

#

they have very lightweight physics so constantly resimming isn't a big deal

#

the result is some amount of rubberbanding

#

vs interpolation where things move rock solid smooth, because they are certain.

vital hawk
weak plinth
#

<@&502884371011731486> channels are automatically dissapearing every time i leave them

#

i cannot find them again

#

nothing is muted

#

something with your bot I think

high night
#

@weak plinth expand the "programming " section for example, you will see all channels

#

If its not expanded, you only see channels with updates

hallow fractal
#

Helloc can someone help me a little with photon here

#

I have pun 2, and i have a train in my scene, but it dosen work,

#

The train hase childs, i tried to put on each child a photon view but it dont work

#

What am i doing wrong

high night
#

@hallow fractal I believe photonview wont work on child object
If they haven't changed how it is
(my info might be outdated)

hallow fractal
#

Soo only the mother needs to have it right @high night

high night
#

Yes

hallow fractal
#

@high night i think i did it before but let me try again

high night
#

Can't put a photonview on a child object afaik

#

@hallow fractal Don't try to put a photonview on players gun for example

#

Have some component in parent that syncs the player's gun over network instead

hallow fractal
#

@high night hmm no it dont work

#

Do you mind if i seend you some pics of the object?

high night
#

k

hallow fractal
high night
#

Only parenting "GameObject"'s transform will be synced

#

@hallow fractal

#

PhotonTransformView doesn't care about child's transform

#

And that includes the train

hallow fractal
#

Soo each vagon needs a separate photon view right?

high night
#

Yes