#archived-networking

1 messages · Page 64 of 1

woven loom
#

We're using strings, afaik.

jade glacier
#

Then it might just be extendable by replacing the lookup code in that Instnatiate method with a check against addressables as well.

#

I'll mention extending the core instantiate to Tobi to include addressables in the future.

woven loom
#

Thanks a lot!

timber mauve
#

hello, do enybody
know about Photon pun

#

because I need a little bis simply help

jade glacier
#

Best bet is to run the tutorials and ask your questions here. Asking if you can ask a question rarely gets replies.

woven loom
#

@jade glacier I guess there is a bug in PUN2. A friend of me has map triggers with colliders. These triggers are disabled when ! IsMine (disabled on the Player), but even if the script is disabled, the collision trigger method gets called. We now have used inMine on the trigger instead of in the script on the player, but that's just bad. If you could forward it, it would be awesome!

little talon
#

so... quick question for photon pun. how would i add a paramater to a room eg: a float. and have weather or now a user joins that room based on that float? thx

jade glacier
#

Does disabling a script stop ontrigger callbacks on unity? Not sure that is a pun related behavior.

woven loom
#

Well, in Player.cs is OnTriggerEnter(). When I disable the Player.cs script, the script won't work and OnTriggerEnter() never will get called. With PUN2 OnTriggerEnter() gets called. No matter if the Script is disabled.

jade glacier
#

That doesn't really make sense though. PUN2 can only be used to control if the script is enabled.... it has no control over if PhysX will generate a trigger event. That isn't part of networking in any way. @woven loom

#

I would check and make sure the things you expect to be enabled and active are right

woven loom
#

I've build a MineMonobehaviour. In Awake() i'm checking !isMine. If so, I disable the script (enabled = false;). Nothing should get called and it's not getting called when I'm not using Photon. I'll recheck what I'm saying, but that's the current state.

jade glacier
#

awake is also likely way too soon to check ismine

#

you should really be doing that in a OnJoinedRoom callback

woven loom
#

Well, the scripts attached to the prefabs are getting disabled.

#

This is working like expected.

jade glacier
#

I'm probably missing your question then

#

but it sounds like you are saying scripts are getting OnTrigger callbacks when disabled,

woven loom
#

They do.

#

😄

jade glacier
#

PUN does not interact with the PhysX system in any way

woven loom
#

I totally get you @jade glacier .

jade glacier
#

Keep in mind that disabling a script and disabling a gameobject are going to be very different - may or may not be related

woven loom
#

But OnTriggerEnter() is in the script which gets disabled. It still get's called.

jade glacier
#

as it should

#

script.enabled doesn't affect trigger events

#

stick your ismine in that ontrigger if you want to ignore triggers when disabled

woven loom
#

I see.

#

A simple if (!enabled) return; should work.

jade glacier
#

if the test is not related to networking, yeah

#

Or disable the gameojbect itself or the collider

woven loom
#

We should've researched enabled first. Thanks a lot.

jade glacier
#

leaving colliders in the physics system may or may not be desirable if you intend to ignore them.

#

If you want to trigger to still work for other components, then check your script like that... otherwise disable the collider/gameobject

woven loom
#

I'll just add

public virtual void OnTriggerEnter(Collider other)
{
  if (!enabled) return;
}```
... to `MineMonobehaviour`.
#

We thought enabled will be enough.

jade glacier
#

that will work, but if your intent is to make the object not in the physics system for all components, then disable the collider. Or you will have to stick that everywhere

#

Just change your code to disable the collider rather than the script

#

Or typically you just put all of that stuff on a child gameoject that you setActive based on if that object is alive and visible

#

when its dead, you disable that child, nuking all things on it... such as the player model, sound generators, cameras, scripts, colliders etc

woven loom
#

It's a trigger on the map which causes the camera to rotate with CineMachine (as far as I can remember).

jade glacier
#

If it makes sense to do it with an enabled check, do that for sure. I have no idea what you are up to.

#

Just saying that test is a very spot fix and in most cases not what you want.

woven loom
#

Yes, you're right.

#

Thanks for helping!

jade glacier
#

np, gl

drowsy quarry
jade glacier
#

the root layer of the animator

drowsy quarry
#

so animator has multiple layers in Unity?

#

I did not know that. Thanks

#

so it must be Unity concept right? this animator layer thing

jade glacier
#

Not sure about other applications, but yeah, you can have multiple layers and they can have masks of what they move.

gleaming prawn
#

steam remote is video streaming... you don't need any netcode for that (but as every streaming solution, good luck)

stray scroll
gleaming prawn
#

local network, yes

vital hawk
#

that IS streaming video for your friend

#

@wispy salmon

#

basically game runs in local multiplayer mode but shares one player input to your internet buddy and streams the video from the computer that runs the game to that remotely located person

vital hawk
#

of course there's regular steamworks networking out there

#

but the remote play feature specifically is just streaming input and video

weak plinth
#

Does anyone know how Minecraft servers work? Is everything client sided but the server just checks if the player is moving too fast or flying for example?

tepid steppe
#

Does anyone have experience with Colyseus?

I've been looking into how people achieve multiplayer games in Unity and a lot of people recommend using Photon PUN, Playfab, GameSparks, or other BaaS.

Rather than using a BaaS, I'd prefer to use a framework/library that's more code focused. I found Colyseus JS, which is along the lines of what I'm looking for but I want to know if there's any alternatives. I've also played around with setting up a simple http/websocket server as the back end, but if there are frameworks or libraries catered towards game networking that could save me a lot of time.

jade glacier
#

I suppose the first questions are

  1. have you made anything networked before?
    and
  2. What are you ultimately trying to make?

@tepid steppe Can't speak to Colyseus though

tepid steppe
#

Game wise, I have very little experience (I used to play around with VB6 and a game engine called Mirage)

I work a lot with web sockets and restful api's in my current job. (Both on the backend and consuming)

I'm ultimately trying to make a turn based game which is mostly single player but actions must be validated on the server, and has some interactive elements where players can play against each other.

jade glacier
#

Cool, that definitely gives you way more networking options. For that type of game you mostly have to work out the simulation, since you will be doing some form of lockstep most likely. And work out how you want to host it. That kind of game is very cloud friendly since it doesn't actually require any Unity-based server logic. For turn-based you really can focus first on the actual game simulation and networking later... but you do have to keep it all deterministic to do that.

#

Not really answering your question, but I would say make a basic turn based demo, like tick tack to or something and try to integrate with the various services, and see if you even need those services.

#

For game networking I STRONGLY recommend against going right after making your dream project, because networking involves like a year of constant failure and refactoring. Way less soul-crushing if you learn all the of the caveats making some crappy little nothing game.

tepid steppe
#

That makes sense. I was planning on making a bunch of crappy prototypes of the core game play for the game before actually starting on the project in order to figure out if the gameplay is fun and to get a stronger grasp on networking with games.

That's a good idea, I'll try making a simple game with multiple services to see if I need them or not. I've already played with Colyseus which I found pretty pleasant to use.

In your opinion, what are some of the caveats people often run into when dealing with networking in an online game?

jade glacier
#

Almost always its starting with messaging, rather than simulation.

#

If your simulation engine is determinstic and tick based, then networking just becomes a function of storing user inputs and resulting states in buffers.... and then using messaging to share those.

#

If you start with messaging, you will tend to start throwing messages, RPCs, and Syncvars around and end up with a tangled mess of race conditions.

#

Messaging <--> Input/State Buffers <--> Simulation

#

Messaging and simulation should never touch.

#

And if you can make it deterministic, it looks more like Messaging <--> Input Buffers <--> Simulation <--> State History Buffer

#

@tepid steppe

tepid steppe
#

Sorry, I had to google some of the terms you mentioned as I'm pretty new to game development itself. This is definitely a lot to think about and I appreciate your info as it gives me a lot more direction for what I need to focus on. I'm going to take your advice and try making some smaller games to get a hold of networking in games haha

jade glacier
#

gafferongames.com has a lot of good articles for new net devs as well. Worth poking around his site.

tepid steppe
#

Thanks for sharing, I'll take a look through their site

mild salmon
#

Does anybody know the best way to stream video on a WebGL build?

vital hawk
stray scroll
#

finally

grand robin
#

Hi, I'm relatively new in unity, is the new networking system working or should I go with UNET? help please

gleaming prawn
#

neither

jade glacier
#

Any first attempts at networking will be pretty much garbage anyway. Just play with tutorials for Netcode, PUN2, Mirror, Bolt and whatever else you think is worth playing with. Don't try to make a real game for a couple months, it will burn you on in an endless cycle of refactoring and failed attempts.

gleaming prawn
#

UNet is dead (if you like the API, check Mirror, the open source version, still in proper development)

#

and DOTS netcode is very very experimental

#

For learning, netcode is ok then, correct

#

But UNet is dead, go for Mirror

jade glacier
#

Once you get through some tutorials for various libraries, you will acquire the vocabulary to even ask the right questions, and be aware of the pitfalls involved in the various libraries.

#

Then you will be ready to understand Erick when he starts talking about the joys of determinism 🙂

grand robin
#

Any first attempts at networking will be pretty much garbage anyway. Just play with tutorials for Netcode, PUN2, Mirror, Bolt and whatever else you think is worth playing with. Don't try to make a real game for a couple months, it will burn you on in an endless cycle of refactoring and failed attempts.
@jade glacier Jajaja I don't have so much time

jade glacier
#

You might not want to go down the networking path if you don't have time to burn, or someone funding your efforts.

grand robin
#

You might not want to go down the networking path if you don't have time to burn, or someone funding your efforts.
@jade glacier Right now I'm developing a simple game in terms of networking (I think so), also I'm working like ten hours a day

#

It's a 1vs1 trivia

jade glacier
#

turn based stuff is super easy, you can use cloud services and such for that.

grand robin
#

And there is any benefit on learning something like mirror in my case?

jade glacier
#

I would tend to say now, since its primarily a messaging layer. It won't be teaching you networking, it will just be teaching you how to user their message wrappers of RPCS and Syncvars.

#

The main advantage of a mid level API, like Mirror or MLAPI, is that they do automate the handling of connecting and creating networked objects with IDs

#

But if you don't actually need a Unity-based server exe, then its going to be for nothing.

#

There would be more benefit in learning how to make your turn based thing play well with like AWS.

grand robin
#

@jade glacier Thanks for your time, I'm going to check a little more of these mid level API, maybe I could add some cool stuff

jade glacier
#

Just be aware that making a game with those WILL require a machine to host a Unity exe.

#

Cloud based like AWS, Photon Server or any other number of libraries are paths to not having to support a host machine.

#

@grand robin

grand robin
#

Ok thanks

gleaming prawn
#

that would be overkill and expensive

#

for a turn based game just try to host the game logic with somthing else

jade glacier
#

You could literally wire up your test game using Google Sheets as your database if you want to get weird. 🙂

harsh dew
#

Sounds like you are speaking from experience lol

jade glacier
#

Nope, never gone there - but would be fun to try.

gleaming prawn
#

I did turn based games for Facebook running game logic on rest services build with Google app engine

#

Works and scales well, pricing was excellent

#

Did this 2010/2012

jade glacier
#

I would recommend whatever you do, abstract all of your code into layers so that whatever database you end up with on the cloud side... its not hard coded into your game logic.

#

I think its just you and I talking now @gleaming prawn LOL

gleaming prawn
#

In a train, commuting back home

jade glacier
#

For the various cloud options, do they offer a pretty wide range of languages you can code your logic into on the cloud side?

gleaming prawn
#

They used to offer a few, python, java, phb, but this was 10 years ago

jade glacier
#

I'm guessing the APIs are pretty insane now

glacial totem
#

Hey guys, if I'm using LiteNetLib or another library to do custom UDP networking, is it common to put network logic in the update loop or fixed update loop?

jade glacier
#

Network logic isn't a thing really

#

That you are using that term makes me want to say no 🙂

#

Simulation logic goes in Fixed, or a fixed timing of your own. That simulation consumes inputs every tick, and produces a new state from applying those inputs to the previous state.

#

Networking is used to sync those buffers as needed between connections.

#

Messing should NOT touch your game or simulation logic.

#

The ideal place for sending messages is after your simulation has run. Or before in the case of sending inputs only, though functionally that will happen on the same tick either way.

glacial totem
#

yeah I'm sending networking packets in fixed update

#

I guess specifically i was wondering is there's any performance benefits with consuming server state updates and applying them in Update() but my guess is that it's all dependent on each game's requirements

jade glacier
#

when you send the packets doesn't matter that much. What you are sending is far more important.

#

Update will make your sends frame tied in a likely not desired way

#

There is no correct answer though if you are not running a strict simulation cycle.

glacial totem
#

my game client has a lot of physics corrections that end up being very CPU intensive on a network state update. I'm trying to do whatever I can to save cpu cycles

jade glacier
#

So simulation = adhoc... = whatever, its all a mess so just do whatever whenever.

#

picking when in the update cycle to send won't save you anything

glacial totem
#

i have a few users who are having performance problems only during networked play so that is telling me it's from that

jade glacier
#

serializing and writing a packet is going to cost the same at the start or end of the update cycle.

glacial totem
#

my physics are 120hz, so Simulating Physics at 120hz and doing it 20 times in a single FixedUpdate is what I'm trying to imporve

#

just seeing if networking could be coming into play here too

jade glacier
#

You want a 120hz net rate as well?

#

120hz for a networked game is going to start testing some limits of a lot of things

glacial totem
#

right now net rate is 120hz but i'm gonna test networking at 60hz tonight

jade glacier
#

Why the high rate? so that you have a high net rate, or just because you need it for your physics model to work?

glacial totem
#

for physics or networking?

jade glacier
#

That is the question

#

Why so high

glacial totem
#

physics is at 120hz for accuracy (I get object tunneling at 60hz)

jade glacier
#

ok, so you don't need that high a net tick probably... so send every X ticks

glacial totem
#

networking is at 120hz just because i'm sending a update from the server on each FixedUpdate currently

jade glacier
#

Are you doing server auth with clients sending only inputs?

#

or are clients doing state transfer to the server?

glacial totem
#

yes

#

only inputs

#

auth server

#

just not very hopefuly the network tick rate decrease will solve this problem

jade glacier
#

Then I would recommend sending inputs at full speed, and have the server send every 2nd or 3rd state out

glacial totem
#

since the client will still be doing 20 ticks of physics at 120hz in a single FixedUpdate

#

just doiung it every other tick instead of every tick

jade glacier
#

The lower the net rate the higher the induced latency, but that is the tradeoff for not crushing your server

#

wait what?

glacial totem
#

The performance problems are on the client side from the physics state corrections

jade glacier
#

Why is a client doing 20 ticks in a fixed?

glacial totem
#

from state corrections

jade glacier
#

20 ticks?

#

how far are you rewinding?

glacial totem
#

rewinding + resimulating physics

jade glacier
#

I guess that is part of the insane tick rate yeah

glacial totem
#

network being a lower tick rate won't change that

#

it will just mean a state correction happens less frequently

jade glacier
#

Cutting your tick rate in half would obviously dramatically cut that CPU usage down

glacial totem
#

Yeah for sure

jade glacier
#

You probably want to revisit what your resim consists of?

#

how much stuff is going into this resim scene?

glacial totem
#

I tried at 60hz for both physics and networking, but it made networking more rough inherently

#

7 dynamic rigibodies total

#

6 players and a ball

#

and all 7 objects are a primitive sphere collider

jade glacier
#

Sounds like you might just be bumping into the limits of using PhysX and you are becoming a candidate for DOTS, or a different physics model

glacial totem
#

Yeah switching to DOTS isn't really an option imo

#

that would be an entire game rewrite

jade glacier
#

You are going to have to give something up it sounds like. If your physX resims are profiling as the problem, you are kind of stuck.

glacial totem
#

yeah i profiled and all the cpu time is coming from Physics.Simulate

#

my velocity solver interations are at 1, my solver iterations are at 4

jade glacier
#

You have optimized that as much as possible?

#

removed everything unrelated and set physics layers as minimal as possible

glacial totem
#

I remember trying Bullet in the past, but it seemed even worse when it came to time spent simulating a single tick of Physics

#

@jade glacier what do you mean with the physics layers?

jade glacier
#

simulating 7 bodies shouldn't be that brutal

glacial totem
#

It's 7 bodies in an arena that has a non-convex mesh collider on it

jade glacier
#

are not including colliders that have no business being part of the resim, or that won't interact with certain other colliders

#

Mesh collider might be a big hog

#

try a test arena with just 7 box colliders

#

mesh collider means each face is a collider

glacial totem
#

that's a good idea just for a sanity check

jade glacier
#

or whatever it reduces that mesh to... but its going to be more than a box collider

glacial totem
#

yeah, i just definitely need the complex physics of the mesh for the game to pan out

#

but it's basically like a Rocket League arena shape

#

mostly flat faces, but beveled/curved corners

jade glacier
#

dont know what to tell you. You have to give something up

#

You can fake stuff with a small collection of hand placed primitive colliders

#

Try the basic map colliders first and see if that even gets you where you need to be.

#

if so, you will have to give up your mesh colliders and do some hand crafting

glacial totem
#

yeah let me do that sanity check first

#

It's super easy for me to switch to Bullet too if i wanna go down that route as I have in the past

#

Just not sure if the expectation is better or worse performance

#

I.E. if Bullet is even supposed to be faster

jade glacier
glacial totem
#

I just know Rocket League runs physics at 120hz with Bullet without a problem

jade glacier
#

They also aren't using Unity PhysX

#

It has massive amounts of waste built in

glacial totem
#

PhysX?

jade glacier
#

I don't understand the question

glacial totem
#

what has a massive amount of waste built in?

jade glacier
#

yeah

#

physx

glacial totem
#

okay yeah I believe that haha

high night
#

is bullet physics stateless?

glacial totem
#

no

high night
#

rocket league is not using a stateless physics engine?

#

how can you do clean rollbacks/resims without a stateless physics engine?

glacial totem
#

what do you mean?

jade glacier
#

you make a second scene with very thin clones of just what is needed

#

basically a scratch pad scene

glacial totem
#

why do you need to even do that?

jade glacier
#

apply the rewound state, reapply inputs, and copy the results back. That is if you are doing fractional tests and will be culling things from the resim.

#

If you are doing a complete resim you can do it in the main scene.

glacial totem
#

okay yeah that's what I'm doing

jade glacier
#

You would then apply the states from the rewind point to everything (which has to include velocites) and then resim

#

its not deterministic though I don't think

glacial totem
#

correct

jade glacier
#

leaving

high night
#

I tried to go single scene only

#

Afterall a single scene should be enough since i can just save/load states and simulate whichever i want, i though

glacial totem
#

as long as you save/load state for everything

high night
#

But then this physx cache ruined my happyness

#

Can't save that cache

glacial totem
#

I'm not having any problems in my game with that

high night
#

and all the invoked OnCollision functions, unapplied forces etc

glacial totem
#

Granted, I don't need 100% determinism since the scene gets corrected extremely frequently

#

Physics corrections and resims are working with PhysX well enough for a playable game though

high night
#

server - host

if(tickTime){
  LoadState(lastReliableState);
  SimulateUntil(serverTime);
  lastReliableState = SaveState();
  SendToClients(lastReliableState);
}

SimulateUntil(predictionTime);

This was my problem pretty much

#

When to go to past with LoadState(), you can't reload past state's physx cache
And bring in a different physx cache from predictionTime

glacial totem
#

oh i'm not familiar with a use case of server-side rewinds

#

Every physics networking design I know of only involves needing to resim on the client side

high night
#

This is a case where server also plays 😄

glacial totem
#

ohhh okay

high night
#

as host you know

glacial totem
#

if the server is playing though, they shouldn't need to ever rewind

#

if they are the authoritative figure

high night
#

takes back where it left the server simulation,
simulates a little,
and then uses that info as if it was a client

glacial totem
#

idk i can't think of a reason so have the server resim

#

Not saying it's wrong

#

Just doesn't make any sense to me

high night
#

server player needs to see future too

glacial totem
#

why though?

high night
#

but in future, other player inputs arent recieved yet

#

server plays the game as well as a player
its host

#

?

glacial totem
#

it just still doesn't make any sense haha

high night
#

hm

glacial totem
#

i don't see what you are gaining from that other than giving the host "fake" latency

high night
#

it's not fake latency,
those inputs from other players aren't complete yet

glacial totem
#

the other clients will be in the future compared to the host, but the host doesn't need to be in the future

#

right, which is why the clients are ahead of the server in tick correct?

#

if the host is on tick 100, the other players will/should be on like tick 110-120

#

so that by the time their inputs reach the server, that tick hasn't been processed yet

high night
#

host reliable state will be at 100 too,
but host will see tick 120
all clients are seeing tick 120 as well

glacial totem
#

that's what I'm saying

high night
#

okay then

glacial totem
#

the host doesn't need to see tick 120

#

It doesn't serve a purpose

#

just show the host tick 100

high night
#

then the hosting player would have input latency?

glacial totem
#

why would they? their inputs aren't going across a network, so you would be processing their inputs directly

high night
#

you register hosts input at frame: 100 or something?

glacial totem
#

i think you are trying to treat the host's inputs the same as a remote client when you don't need to

#

when the server/host is processing inputs for itsself, all it needs to do is take the current input in real time

high night
#

Then you'd have to register the input at server's reliable time the frame=100

#

Is that what you are doing?

glacial totem
#

if (player.isRemote) //find input packet matching the tick and process it
if (player.isLocal) // player.inputs = Inputs.GetKeyDown(), etc.

#

all host input should be 100% realtime

#

it shouldn't need to be buffered

high night
#

but host lives in the past compared to clients

glacial totem
#

and then the host shouldn't be in the future

high night
#

this isn't normal logic right?

#

this is something weird but works in practise type of weird?

glacial totem
#

let me ask you this

#

if you took your game, and made a dedicated server

#

so that all players are remote

#

would your server still be resimulating physics?

high night
#

yes

#

that 20 frame window is fixed in my code

glacial totem
#

do your clients currently resimulate physics at all?

high night
#

yes

#

everytime they recieve a new state

glacial totem
#

i think you have flawed logic in your server logic then

high night
#

i was going to send the state immidently as soon as all player inputs for the tick is recieved
haven't done that yet though

glacial totem
#

maybe I just don't understand your game design

#

what kind of game is it?

#

your server should never "wait" for player input

glacial totem
#

yeah i don't see a reason you would ever resimulate physics on the server for that

high night
#

this is the game, i have mp version too but havent uploaded yet

glacial totem
#

the clients should be the only ones resimulating

high night
#

I want to have melee combat

#

like chivalry

#

or mordhau

glacial totem
#

got ya, I played Mordhau

#

But yeah, resimulating physics on the server sounds like the incorrect approach for this style of game

high night
#

@glacial totem Wait if i had the server as a dedicated server, i wouldn't run any resims

#

only on clients i mean

glacial totem
#

okay that makes a lot more sense

#

then if you wouldn't resim on a dedicated server, you shouldn't resim on a player host server either

high night
#

server would send state as soon as inputs from all players recieved for the tick

glacial totem
#

The host's server should work exactly like a dedicated server would

high night
#

no, player host would have to wait just as long as everyone is waiting
and resim with the state from the past

glacial totem
#

but the host's local player doesn't do any networking and doesn't live in the future

#

yeah i think that's flawed

#

what is the server waiting for?

#

inputs?

high night
#

inputs from all players must be recieved per that tick before server sends out a state

or in 20 frames at max and then server sends the state

glacial totem
#

so what happens if one player lags

high night
#

its the max latency for a player

#

inputs are rejected

#

and player rubberbands and cant move

glacial totem
#

yeah i think you might have the wrong approach to your problem

#

server shouldn't be waiting for anything or doing anything complex

#

it should simply get all the inputs it has for the tick it's on, process them, increment the tick number, and repeat

#

if a player's input isn't there yet, or it's not reaching the server on time, that's a problem you solve on the client side

#

all clients should be in the future, but based on their own logic

#

client 1 has 30ms ping, client 2 has 50 ms ping, so client 2 should be more ticks ahead than client 1

high night
#

oooh i see now

#

laggier the player more in the future

glacial totem
#

exactly!

high night
#

more time for input to reach server

glacial totem
#

if the inputs aren't making it in time. what I do is I have the server tell the client it's behind

#

and the server tells the client it needs to more ahead into the future more

high night
#

hmm, thats kinda weird to think about though, living in different times

glacial totem
#

yeah but it makes sense

#

me and you are on the server, and the goal is that both of are inputs are processed at the same time so it's fair

#

but if I'm laggy, you shouldn't be punished

#

that's my fault and my problem, no yours

high night
#

So if a player is too laggy, does that player see a falling box hit the ground earlier on his screen?

glacial totem
#

yeah, the laggier the player the more extreme corrections might be

#

have you ever watched the Rocket League GDC talk?

high night
#

i did but i may not remember details

glacial totem
#

They explain the entire system they use, and all I did was watch that video and try to copy what they did

#

and I'm having a ton of success

high night
#

with physx huh

#

so about physx, we run two scenes on clients right?

glacial totem
#

I'm not

#

I only run a single scene

#

when i get a state update from the server, i rollback my entire main scene, then resim, then continue on as normal

#

The catch is that you would need to resimulate all objects

#

so for you that would be every single player and every arrow, etc.

gleaming prawn
#

@glacial totem the pwrf numbers you are getting seems very bad

glacial totem
#

for me that's only 7 objects total: 6 players and a ball

gleaming prawn
#

I know we can do 20 tick rollbacks with a simple rocket league like game no problem with our 100% deterministic physics

#

That's not even a question

glacial totem
#

at 120hz?

#

and what physics are you using if you don't mind me asking?

gleaming prawn
#

I'm saying we can run 20 ticks at once no problem...

glacial totem
#

I agree that it doesn't seem like something that should be as performance heavy as it currently is

gleaming prawn
#

But I'm talking about our own stateless physics engine

glacial totem
#

is that a proprietary solution I'm assuming?

gleaming prawn
#

I expected a non deterministic one to be faster, but physx is not made for rolling back

high night
#

But what about oncollision invokes,
If a collision is invoked the frame you recieved a new state
And you did the rollback on that state

That collision will leak into the that past state, ruining your 10 - 20 frame determinism

@glacial totem

gleaming prawn
#

So the cost must be in the creating the broadphase or even the state copy

#

Well, yes, proprietary.... But your physics requirements seem low for running into issues with physx

#

But maybe I'm underestimating how bad it is for rollbacks

glacial totem
#

@high night it all depends on what those collisios trigger. for me personally, the incorrect collision is discarded and the new one generated from the resim is used

#

@gleaming prawn that's why I'm also open to using another physics engine

gleaming prawn
#

As emotitron always says, I'm just glad I do not even have to think about the problems you are describing...:)

glacial totem
#

physx isn't even deterministic, so having determinism for my use case would be so much of an improvement

high night
#

@glacial totem you are able to serialize the collision in states?

glacial totem
#

@high night i only ever use oncollsionenter

gleaming prawn
#

Ours is a complete multiplayer game engine, and yes we built a rocket league for mobile with it already (30 or 60 Hz because mobile, could run at 120 on pc, no problem)

glacial totem
#

Collision Stay and Collision Exit aren't used in my game

gleaming prawn
#

Is this a proper game you want to release, or just a hobby project?

glacial totem
#

@gleaming prawn 100% intent on releasing at this point. Started as a hobby but I think it has potential.

gleaming prawn
#

Even if just a hobby, we're always interested to contact good Devs for potential collabs (not necessarily we need to think of anybody as a customer)

glacial totem
#

The people testing are playing the game on their own and enjoying it. They aren't being forced to play. So I think that's something

gleaming prawn
#

Looks cool, is it just a rocket league clone?

high night
#

@glacial totem Are you not serializing the collision forces in OnCollisionStay?

#

I mean, those forces don't affect velocity immidently so if you serialize before next frame, you'll be missing that info
And in the next frame you already have new forces generated and haven't yet applied to velocities

jade glacier
#

Yeah you will need the velocity and angular velocity in your state sync

high night
#

There's no right time window to serialize and create a correct state with physx i thought. As soon as the physx uses it's cache to update transforms and rbs, it creates another cache. That cache might even have information from previous states who knows.
Thats why i'm trying to use the new Unity.Physics in dots

jade glacier
#

I have had moderate success in the past of polling RBs post Physx.Simulate(), but its very much not deterministic. He is mostly going for close enough though since its in a constant state of resim

solar rain
#

Hi all i am working on FPS Multiplayer project and i will be using AWS server, can anyone please tell me if amazon have different packages for multiplayer and does the programming C Sharpcode differs based on the packages i will be opting?

drifting ridge
#

Hi, is there a Photon specific discord server or can I ask my photon pun 2 related questions here as well?

weak lava
#

So with a bit of precision lose it is possible to pack 2floats into 1 int. My question is is this possible with 3 floats in a small range ? Like x,y,z are in between -10.0 to 10.0 with at least 1
decimal point.

gleaming prawn
#

you can store 4 floats in one Int

#

using Q4.4 (but that is in the -7 -> 7 range only)

#

and very very low precision

#

or Q5.3, which would give you the integer range you want

weak lava
#

what is Q4.4 n Q5.3 ?

#

@gleaming prawn

gleaming prawn
#

FixedPoint formats

#

that's what is normally used for cross-platform determinism (RTSs, we use in Quantum)... In our case Q48.16 (Int64)

weak lava
#

Interesting!

jade glacier
#

I think that is what you are basically asking about, options for bitpacking floats?

#

It handles rotation and scale edge cases, gives the option for an accurate center value, smallest three quat compression and half floats

weak lava
#

Yea right. I know your lib, but thanks. I need to learn that kind of stuff so i will go for implement something on my own^^

jade glacier
#

The math is pretty basic, its what Erick posted a link to. Its just a pain when you want to start dealing with the edge cases, like compressing and recreating euler rotations that will wrap all screwy if you don't build in handling for that.

weak lava
#

Thanks, gonna look at it^^

jade glacier
#

His libs are pretty heavily tested for speed, we benchmarked his stuff and mine pretty heavily.

gleaming prawn
#

Thanks @jade glacier was unaware of these libs

jade glacier
#

He does networking on a massive civil war simulation, and it sends one giant single state to all players, so his entire system lives and dies by his bitpacking speed

#

I don't know though if he has added unsafe read/write and a means of locking the buffer for that. That was the one spot my lib was much faster.

#

@gleaming prawn Don't think you will have much use for either at this point LOL. You kind of have something way different and better 🙂

gleaming prawn
#

I know

#

But still nice to know about them

quasi tapir
#

Is there any way of knowing in Photon when the value i streamed has written to the other client so I could reset it?

jade glacier
#

Probably not in the way you are hoping

#

Since there is no server, trying to check acks against all clients by each owner would become a tangled mess.

#

You CAN send your message as reliable though

#

and it will stop all traffic until that message gets through.

#

It will make a mess of any fast streams you might be trying to achieve, but it will ensure delivery to all.

quasi tapir
#

Oh, does this apply if i have two players as well?

jade glacier
#

Any number of players, it tells the relay that that message needs to get through at all costs

#

The relay handles it and will do the RUDP work needed to ensure all targeted clients get it

#

But it can hold up other traffic, so I try to avoid that and instead opt for keyframes for eventual consistency.

#

But you can easily give it a shot, just flag your RaiseEvent or RPC as reliable or reliable ordered.

#

depending on your needs.

quasi tapir
#

Got it, will try sending a message to see if it works

jade glacier
#

if you send it as reliable unordered I don't think you will mess with other traffic getting through

#

so you can make your fast unreliable stream, and then send stuff that doesn't need to happen on tick as reliable... like say a score change or some other thing that won't mess with your simulation.

quasi tapir
#

My needs are simple, I just have an int check to enable an attack animation prefab. So when player 1 presses a button, I increase the number of his int, I check if the number of the other player's int is equal to 1 or 2 and spawn an animation accordingly. This messes up since I cannot reset the int and the prefabs keep spawning till I change the int on the initial server

jade glacier
#

you are starting to get into simulation there, so you are going to be going down a messy path trying to turn your simulation stuff into adhoc events like that

#

It will all work when you are starting and you don't have a lot of race conditions, but as your game gets complex and order of execution becomes critical that adhoc timing will become a nightmare.

#

So forewarning.

quasi tapir
#

Yes, it's getting cluttered as it is, will try messages and let you know

jade glacier
#

No need, I know how its going to turn out 🙂

#

Its going to work fine. The issue is as your game logic starts to get complicated the uncertainty of events arriving and processing in correct orders is going to force you to start over and go tick based.

#

Everyone though has to try the short and easy route first though, to find out why the harder way matters.

quasi tapir
#

Yes, thanks so much for your help 😃

weak lava
#

XO i got a weird idea, since i know the exact map size. And i already can pack 3 floats (0.00-1.00) into 1 float. I can use it as a percentage. ```cs
public static float Pack(Vector3 v3, Vector3 min, Vector3 max)
{
var x = (v3.x - min.x) / (max.x - min.x);
var y = (v3.y - min.y) / (max.y - min.y);
var z = (v3.z - min.z) / (max.z - min.z);

        var retVal = ((int) (x * 65535.0f + 0.5f));
        retVal |= ((int) (y * 255.0f + 0.5f)) << 16;
        retVal |= ((int) (z * 253.0f + 1.5f)) << 24;
        return retVal;
    }

    public static Vector3 Unpack(float f, Vector3 min, Vector3 max)
    {
        var i = (int) (f);
        var x = ((i) & 0xFFFF) / 65535.0f;
        var y = ((i >> 16) & 0xFF) / 255.0f;
        var z = (((i >> 24) & 0xFF) - 1.0f) / 253.0f;

        x = min.x + (max.x - min.x) * x;
        y = min.y + (max.y - min.y) * y;
        z = min.z + (max.z - min.z) * z;
        return new Vector3(x, y, z);
    }```
jade glacier
#

I 100% encourage making hot messes when learning networking. As long as you have time and its fun.

#

@weak lava That's called normalized, but not really needed, its just an extra math step for no gain.

#

If you know the map size, you are already in a winning place for converting your floats into uints and bitpacking those.

#

All you end up doing is creating an encorder and decoder value to multiply against, and then you add the lower range value. That won't make sense as text, but its very basic.

jade glacier
#

I'm not reading all of that, but be aware that if you are picking up items, they are going to likely have a different owner.

#

So you will have to work out the exchange of ownership, or include reparenting info in the transaction.

#

If would include it in the RPC, so it all happens on the same operation without producing race conditions yeah.

#

Shared objects are notoriously tricky, especially in a relay environment

near cairn
jade glacier
#

Is that PUN2 or PUN ?

near cairn
#

i fixed it

solar rain
#

Hi all, I am working on Unity(2019.3.2f) FPS Multiplayer project and I am planning to opt for AWS(Amazon Web Server) can anyone please tell me if amazon hasI different package for multiplayer and does the programming code differ based on the packages i will be opting?

wanton scroll
#

Hi. We are using PUN2 any idea how to deal with piracy ? Lets say our steam game gets cracked how do I stop the pirates from playing. The game is only mutiplayer.

gleaming prawn
#

@wanton scroll piracy is something you need to deal with the tools from steam (distributor) and your own. Photon has no relation to what you can do there....

#

Photon has external authentication options that can force your players to go through. For example steam Auth or Facebook, etc

#

That helps you to make sure players are at least logged users....

#

If you enforce via steam, maybe that helps...

#

But that is not strictly a photon tool, they just accept external authentication before a player can get into matchmaking, etc

wanton scroll
#

I was thinking that exact thing. I just dont know if they crack our game if it will not show up in steam so to speak.

gleaming prawn
#

This would not prevent a player form downloading from other sources, but at least it might prevent these from playing, if your Auth identifies players who own the game copy

#

They will crack, but these authentications happen on the server...

wanton scroll
#

Our game is just multi player so that shouls be reasonable enough protection I think

gleaming prawn
#

So they would not be able to login to the official servers unless they own a copy (assuming your steam Auth can enforce that)

#

Glaubst Just pure piracy it might help, yes

#

Authentication and rewarding player with progress prizes is one of the major ways the industry is dodging piracy

#

Online only, etc... Free to play...

#

Challenges are others... Not piracy (at least for online only)

wanton scroll
#

Ah I can set check ownership in the pun dashboard and just send the steam session ticket

#

That should teach those pesky pirates🤣 😀

gleaming prawn
#

There is documentation on how to setup custom auth

#

Not sure if steam is turnkey, it might be.

wanton scroll
#

Than you yet again for the great info.

prisma girder
#

It's pretty turnkey. Using the SDK hooks Steam, and if you're logged in, you can get a session ticket, which serves as auth

wanton scroll
#

Yeah I found this too. I was rather asking if this is enough to stop pirates from playing our multiplayer game

weak plinth
#

Guys, i have never heard about how to make an multiplayer game or anything, but how does Photon actually work

#

Like how do you connect to a server

#

Make a server

prisma girder
wanton scroll
#

@weak plinth there is very decent documentation on the pun website. I've never made a multi game too and using that I was able to make our latest game

prisma girder
#

tl;dr, yes. The session ticket system is used to verify a user's Steam identity, and can be used to verify ownership of the game, as well as other profile information, like VAC bans

#

So a hypothetical pirate -- by which I suspect you mean someone who didn't pay for the game but has the client -- can't play without a valid Steam account that owns it, if you use session tickets to auth them

weak plinth
#

@wanton scroll but how do you make your own server, can you host one online or do you use your pc

wanton scroll
#

You dont

weak plinth
#

I only want to know that

wanton scroll
#

Pun is the server

weak plinth
#

Ok

#

Thanks

wanton scroll
#

Its cloud and has load balancing

weak plinth
#

Thats amazing

#

I will try it once

#

Is there any price for it

gleaming prawn
#

There are different ways to develop multiplayer piki

weak plinth
#

Or is it free

#

Im just talking about pun

#

@gleaming prawn

wanton scroll
#

And in my calculations it's cheaper than renting actual virtual servers

weak plinth
#

Ok

wanton scroll
#

Pun is free up to 20 ccu

weak plinth
#

Ok

wanton scroll
#

Ccu is concurent user

gleaming prawn
#

Your question seems you do not understand exactly how pun works, there is another product from the same company which you might relate better

#

Photon bolt.

weak plinth
#

Is it like paying monthly?

#

If yes

#

How much

gleaming prawn
#

That one uses a pure client server architecture, and you can either have players host servers or yourself dedicated ones

#

Free for up to 20 sinuktaneous

#

Then the prices are in their website

wanton scroll
#

@weak plinth just go to the website

weak plinth
#

Ok

#

I will

prisma girder
#

There's also Amazon Gamelift, SpatialOS, a few other similar services

gleaming prawn
#

There's no free product from companies... Unity offers their for "free", hoping you host.yourbgames with their servers

#

Unreal takes a decent amount of your revenue if you get successful, etc

#

Free free, you can get mirror

#

But then you still have to host servers

#

So, no free...

weak plinth
#

Yeah, i just checked, its good

#

I mean google drive lmao

gleaming prawn
#

Check pun, bolt, mirror

weak plinth
#

Free

gleaming prawn
#

See which one you like the most

weak plinth
#

Yeah

#

Im not really looking something professional cuz i cant even develop a professional game

#

But i will remember that

gleaming prawn
#

Try the free versions, you will have fun

weak plinth
#

Yeah

#

I will

#

But i dont have friends :(

wanton scroll
#

Well if you are just starting your game I would recomend you check out the new unity dots networking

gleaming prawn
#

This is a different forum...:)

#

Really Uri?

#

:)

wanton scroll
#

There you write your own client server that you can host somewhere free for your friends

gleaming prawn
#

I'd use mirror for that

prisma girder
#

I would recommend against the new DOTS networking, especially for a beginner, and especially right now

gleaming prawn
#

Until dots gets anywhere close to stable

prisma girder
#

Mirror is wildly easier

gleaming prawn
#

Dots in general is a complete uncertainty

wanton scroll
#

I went with pun in our project because its stable and easy to implement since we have a very very tight productin schedule

gleaming prawn
#

And it offer no option for punching, relay, so you'd be stick to hosting expensive servers

wanton scroll
#

Exactly not at all usable in a production env like my case

prisma girder
#

Pun is great when you're at the point of having things like production schedules.

wanton scroll
#

But might be fun and educational for him

gleaming prawn
#

Yeah, on a second step

wanton scroll
#

Pun saved my life and studio haha

gleaming prawn
#

It's a bit hardcore for someone starting

wanton scroll
#

Lets just hope we dont all die from corona before we release

weak plinth
#

And i hope we all die

#

The earth

#

🙂

#

Im in Netherlands and corona is almost there

oak flower
weak plinth
#

Im out😒

quasi tapir
#

@jade glacier messages worked like a charm

#

😊 thanks for your help

vital hawk
#

A sample showing a way to implement lag compensation based on Unity Physics. In a game based on the Unity NetCode the client will display an old world state, lag compensation allows the server to take this into account when performing raycasts so the player can aim at what is actually displayed on the client.

jade glacier
#

@quasi tapir I'm not sure what you are doing with that reliable message, but something to test for is if late joiners to the game see the right current state for whatever it is you are changing.

jade glacier
#

@weak plinth not reading all of that, but are you changing owership of that object to the player that grabbed it?

jade glacier
#

I don't see the ownership change at a glance of that code

jade glacier
#

I'm a bit too buried in work to dig through your code or watch the video closely, but might be good to clearly articulate the behaviour. Where its working, where it is not working, and in what way it is not working.

#

"Its not working" requires a bit more sleuthing than I can dedicate while working.

#

What is breaking. It works on the owner/master correctly?

#

Does that replicate correctly?

#

"works" is the word I am trying to avoid

#

there we go

#

the transform state is not replicating to non-owners

#

So two problems?

#

when the master grabs it, it looks right on the master, but does not replicate to other clients?

#

You are syncing the transform with the vanilla TransformView?

#

Before getting too deep into this, you might want to set aside 30 mins and run this tutorial for the new PUN2 stuff - its going to replace a lot of that as standard practice, and it does most of this for you.

https://docs.google.com/document/d/1moPBIt8cNe-h1uG01pvaOZQvrIjZfSBfDmVa793X6AQ/edit?usp=sharing

#

For the vanilla stuff, you use one or the other of those views. Not both.

#

Or they are going to be fighting for control on the non-owners

drifting ridge
#

when testing connections between multiple clients, how to simulate it? do I need to have 5 different phones to test 5 different connections or is there a better way?

weak plinth
#

There are a tutorial for a Photon Multiplayer Online?

jade glacier
weak plinth
#

With this i can make a Online Game?

#

Thanks

jade glacier
#

It will introduce you to the concepts of using PUN. Making a game is more up to you 🙂

#

@weak plinth yeah, you aren't meant to use both of those - just one or the other as far as I know. Otherwise they both will end up fighting to move un-owned objects in their own way.

quasi tapir
#

@jade glacier I just send a messages to trigger a local animation on the other player. I only start the game when both the players are present so there is no issue there with late comers. Although I do have an issue where my timer does not sync properly since I start both timers after both the players join and click the start button

#

I guess I have to change the variable I am sending to confirm I am ready to the player 1 through a message as well

jade glacier
#

I can't speak to most of that, some of that stuff you just described sounds like a recipe for race conditions and such.

quasi tapir
#

This is a word game. Like scrabble but the ones who form the most words in a minute wins. So what I do is have two players join the room, the player 1 waits for the 2nd player to join at which point I give him a random set of letters, when the player 1 gets his random set, I send it through to the player 2 so he gets the same random set of letters as well. When they both get it, they click ready, when the 2nd player clicks ready, a local timer for him starts while he sends a confirmation to the player 1 that he is ready and a local timer starts for him

#

I have minor latency issues with the timer, these aren't identified at the start, but when it ticks down more and more, there is a second or two difference near the end

jade glacier
#

ah, so turn based?

#

You might actually want to consider not using PUN for that.

quasi tapir
#

No turn based, rapid fire under a minute

#

Ah, how so?

jade glacier
#

nm, if its realtime then stick with PUN

#

pure turn based you would want to consider removing all of your game logic from Unity.

#

I'm coding as helping people in this chan btw, so any large walls of texts I end up just skimming, so apologies if I totally misread you.

quasi tapir
#

No problem

#

This is realtime, it is been a really fun experience to getting it to work

#

Now I'm at the part of optimizing it

#

what do you mean remove all game logic from unity if it is turn based?

jade glacier
#

It seems you already aren't trying to run any kind of server/database logic so it doesn't really apply to you.

#

But for turn-based you would typically have a database/cloud of some kind that acts as the server, and all turns would go through that. But because its not a physics based game, you wouldn't want to have to host a Unity EXE as your server, you would want to reduce your code to something that can be run outside of Unity, or run as a script or plugin on the cloud server.

#

For Photon Server that would be a plugin, for like AWS that would be some scripting.

#

MUCH cheaper to host your logic like that than have to spin up Unity instances.

#

You however are letting the clients run the logic it sounds like, and you are trusting them. Thus removing that need, as you are basically letting the Master Client act as your server.

quasi tapir
#

Yes, you are right, I don't have any database logic as of now

#

Client runs the logic locally, I'm using Photon for matchmaking and for sending data. I do have tons and tons of animation though, so Unity helps me greatly with this. There is a single player campaign mode as well with multiple levels

jade glacier
#

If you eventually intend for the logic not to be trusted to clients, you might want to wrap that into its own simulation class.

quasi tapir
#

You mean I let the server take care of all the logic and just display it on the client?

jade glacier
#

That isn't required, but if you can make your simulation deterministic (you should for turn based) - then the server and the clients run the same simulation from the same user inputs.

#

Your networking becomes very tiny, as its just sharing those inputs. Typically in a lockstep architecture to make it nice and easy.

quasi tapir
#

Ah, I don't understand it clearly, but you are suggesting I just track the inputs which control certain sets of game logics which is common for both the players in case of a turn based game instead of tracking every variable that is changed

jade glacier
#

That is how game networking normally works. Beginning devs tend to just do everything as messages being thrown around, but once you realize the hell that creates down the line you will want to move toward creating a simualtion.

#

The simulation is like how PhysX works... it has a regular tick rate, and before it simulates it collects inputs for the next tick (What you do in FixedUpdate) and then once all of that is collected you apply those inputs to the results (state) of the previous tick.

#

Networking then just becomes the passing of the contents of those ticks around.

#

Messaging <-> Input / State Buffers <-> Simulation

#

Messaging and simulation should never directly touch in code.

#

Once you have your simulation abstracted, then it doesn't matter where it is, its just there to apply inputs to a previous state, and produce a new state.

#

Deterministic means that no matter which machine you run that simulation code on, you will get the EXACT same state results.

#

That allows you to only transmit inputs (cheap to network), and you can trust that everyone will produce the exact same result (State - which is expensive to network in most cases)

#

You can also sync the states if it makes sense instead.

#

What matters is that everything is reduced to inputs that go into the sim, and states that come out of the sim.

quasi tapir
#

This makes so much sense, feel like this would be easier if you want to disconnect and reconnect as well to start from the last point

#

I will try shifting my code like this soon when I get a full working flow of it with messages 😄

#

This is pretty informative, thanks a lot for taking the time to explain this

jade glacier
#

Never used nor heard of those. But I also don't use RPCs so I don't know much about their usage with PUN.

desert flare
#

How would one use UnityWebRequest to POST binary data to a web service? (or barring that, another alternative)

#

(The endpoint is not ours and it expects binary data, bu UnityWebRequest only seems to allow string data)

prisma girder
#

Define "binary data". What Content-Type does the remote API specify?

drifting ridge
#

In photon pun, host migration is auto

#

How can off the host migration?

#

So that when the master leave, the game ends

jade glacier
#

Just use the PUN callbacks

#

there is one for master change I believe

#

OnMasterClientSwitched

#

@drifting ridge

drifting ridge
#

@jade glacier thanks, it works

stable epoch
#

Any suggestions for cheap reliable servers??

#

All I really know is AWS

weak plinth
#

@stable epoch host at home UnityChanLaugh

near cairn
#

im pretty confused with this whole [PunRPC] thing. say i want to send the mesh renderer from a player to the server so everyone sees the player in their full glory.

[PunRpc]
void sendMeshRenderer(MeshRenderer mr){
  // what now
}
#

or is it a whole different thing

jade glacier
#

Not even sure what sending a MeshRenderer would mean... that's not likely to be a networked hash

#

Its not going to serialize the entire mesh for you and reproduce that if that is what you are thinking.

near cairn
#

ill send you a gif of my situation

jade glacier
#

Not sure that will help any, what you just typed and your code indicates you want to send an entire serialized object... which isn't going to happen.

near cairn
#

ill also send the script responsible for setting the color of the materials

jade glacier
#

"sends the script" ?

near cairn
#

the piece of code

jade glacier
#

Just make an RPC called "SetColor" and send the vector3 value you want to set or something.

near cairn
#
        if (PhotonNetwork.IsMasterClient) {
            if (PhotonNetwork.CurrentRoom.PlayerCount % 2 == 0) {
                GetComponent<MeshRenderer> ().material.color = teamColors [0];
            } else {
                GetComponent<MeshRenderer> ().material.color = teamColors [1];
            }
        }
jade glacier
#

or more ideally, index your colors, and send the color index

#

so just networking the team index

near cairn
#

exactly

#

i dont know how to make an rpc to set the color

jade glacier
#

You can't serialize an entire Object and hope it actually replicates... it won't do that.

near cairn
#

i saw a really confusing tutorial

jade glacier
#

How would you normally make a method that sets the color?

#

yeah, whatever tutorial fed you this... needs to get thrown in the trash.

near cairn
#
GetComponent<MeshRenderer> ().material.color = Color.myColor;
jade glacier
#

rpc the team value... and have each client set the color based on that index

#

you can RPC color, its a vector3 or vector4

near cairn
#

oh so just

void color(Color clr){
GetComponent<MeshRenderer> ().material.color = clr;
}```?
jade glacier
#

If that is what you are after, yeah. Just RPC that color value

#

or if you have a finite number of colors, just rpc the team index

near cairn
#

ok

#

thank you so much

jade glacier
#

Though that is a whole other networking can of worms... because RPCs are =NOT permanent states

near cairn
#

i think i finally understood rpc's now

jade glacier
#

so late joiners are going to not get that message

near cairn
#

oh?

#

i remember the tutorial dude saying something about new clients

#

do i set RpcTarget.AllBuffered?

jade glacier
#

I don't touch any of the RPC stuff, can't really speak to actual best practices for that.

near cairn
#

well seems like color is not valid here though i fixed it fairly quickly

#

thanks again

#

seems to do the job for now

jade glacier
#

np

jade glacier
#

Are you sure the ownership has changed for starters? Like use Debug.LogError() to print things to your development builds visible log and put checks there to make sure things are as they should be.

#

But exchanging ownership of shared objects is never trivial, you have to be very exact in what the conversation is between the original owner and the one grabbing the object.

#

There is always a period of confusion between when the player grabs it and when the current owner and others recognize that new players as being the owner.

#

I am not entirely sure what is going wrong, but a glance at the video looks like there is latency between the player looking around, and the object following in a delayed manner, which indicates that the player doesn't own the object.

#

Side note on doing that well, you will typically want to must network that object having a parent change, rather than networking its global position every tick.

#

If you tell it that it is mounted .2 units in front of the player, then you don't need to constantly sync the position and rotation. Every player will just see it .2 units in front of the current owner.

#

Disable the transform/rb sync if you do that

#

Not sure if the vanilla syncs allow for "local", but that would also solve the issue if they don't sync by localposition and localrotation already internally

jade glacier
#

Disabling the component might be respected by PhotonView's serialization... not sure.

#

Yeah, no idea - I don't mess with RPCs for what you are doing. I literally am working for Exit making a system that handles all of this.

#

SNS

#

Would be interested to know where it fell down, because it's ultimate intent IS to work for everybody.

#

Fair enough, though not super informative 🙂

near cairn
#
void FixedUpdate
                if (PhotonNetwork.IsMasterClient) {
                        stuff
        } else {
            Destroy (deleteForClients);
//deleteForClients is a GameObject which includes a camera
        }```
this returns me a really weird result:
when the first client joins - the object is not destroyed and everything is fine.
when the second player joins - the second client seems to destroy the first client's object, and now the first client sees through the second client's camera. also what i typed in `if (PhotonNetwork.IsMasterClient)` seems to also try and work for the second second but the second client seems to snap back to where they were before in the next frame.

i believe the if statement is not the correct one
jade glacier
#

are you sure the network has started by the time that first Fixed runs?

#

otherwise all ownership bools are going to be false

near cairn
#

what do you mean

jade glacier
#

Not sure how else to phrase that

near cairn
#

"the network has started"

#

you mean when the client connected to the servers?

jade glacier
#

that this OnJoinedRoom has run and ownership exists

near cairn
#

holy shit i forgot about this part

#

what was it again

#

i remember you told me what to do

#

no wait

#

that wasnt it

#

the OnJoinedRoom was called ofc

#

how can i check if ownership exists

#

if (PhotonNetwork.IsMasterClient) print("ownership exists");?

#

@jade glacier im confused again

#

yeah i understand

#

i found the error i think

#

it's gotta be "pv.IsMine" instead of "PhotonNetwork.IsMasterClient"

#

pv being PhotonView

jade glacier
#

keep in mind what you are doing there with destroy means that that object should never change owners.

jade glacier
#

yeah, transferrequest or something like that. Don't recall off the top of my head but its easy to look up

#

Keep in mind that its all asyncronous in nature, so you need to build in tolerance for things not happening in the order expected.

harsh dew
#

Oof, transferring ownership always brings problems

jade glacier
#

yup

harsh dew
#

I think the default owner is the MasterClient

mint acorn
#

Can anyone explain what's mean?

wild trellis
#

unity html5 c# how i can to do something{} if web page refresh/close

ocean slate
#

how would i change a networked players position with something like gameObject.transform.position without it like breaking

jade glacier
#

Are you using a particular library?

ocean slate
#

hlapi

#

when player dies i want him to teleport somewhere to get respawning animation and teleport back to respawn point

jade glacier
#

Are you using networkTransform?

ocean slate
#

yeh

#

it like on client that died he dont tp back but on remote player (one that didnt die) it shows him floating in air where he should spawn

#

and falls down when dead person moves

#

its like rlly broke

jade glacier
#

Teleporting is usually pretty jacked up with the vanilla transform syncs in many of the free libraries yeah.

ocean slate
#

is there a dif way to do it?

jade glacier
#

If you are trying to handle it yourself, likely will want to set the rb to Lindsay while dead, an disable interpolation for the teleport

ocean slate
#

im usin charcter controller

jade glacier
#

Hard to say, not sure what is wrong with your code currently.

ocean slate
#

and have no clue what interpoltion is

jade glacier
#

Doors it teleport locally correctly?

ocean slate
#

it teleports player dead if it is !localplayer

#

but wat rlly confusions me is it fine tping to area for when dead but when tping back it just fails

#

the player that died doesnt move after dead animation

#

but for other players he floatin

jade glacier
#

To many unknowns to say without all of the code and player objects in front of me, sorry.

ocean slate
#

thanks for attempting 🙂

#

first person to actually reply without giving me a link to google.com and telling me to look it up

drifting ridge
#

[Photon Pun 2] Does changing the player properties of client A from the master client informs that the property of client A was updated for all clients in the room?
Also, if a new player joins the room, can the player get the updated property from client A using it's actorNumber?

I know changing a room properties is 'global' and you'd be able to get the updated value but I'm not too sure about player properties.

turbid forge
#

Hello, I was wondering if anyone ever used enet for networking, and if so you probably ended up using the c++ lib and use a wrapper or? Are there any other ways to use this library? I can not find a good port of enet to C# without any dependencies, so I want to create one that is closely inspired by the c++ code.

I am asking what are your thoughts about this, is it worth it or am I missing a point that makes this unnecessary ? And lastly if anyone would be interested to help if it makes sense to build something like that.

Thank you for reading 🙂

mint acorn
#

Try this

turbid forge
#

I am aware of this, but it is not managed(use c++ dll) and its archived, so maybe no future updates. I think there is nothing wrong with the c++ dll / wrapper, but personally I would love a c# managed way (even if performance is lower) What are your thoughts?

jade glacier
#

Buffered rpcs in PUN should be used very sparingly. They are not a substitute for states, and will cause problems if you have too many, like later joining players getting disconnected.

weak plinth
#

Someone pls help me

#

Im trying to make a multiplayer game

#

Trying to sync players but they dont appear for all clients

#

Im using photon

#

Thats my join script:

#
    {
        PhotonNetwork.ConnectUsingSettings();
    }

    public override void OnConnectedToMaster()
    {
        Debug.LogWarning("Connected!");
        PhotonNetwork.AutomaticallySyncScene = true;
        PhotonNetwork.JoinRandomRoom();
    }

    public override void OnJoinRandomFailed(short returnCode, string message)
    {
        Debug.LogWarning("No rooms, creating...");
        RoomOptions roomOps = new RoomOptions()
        {
            IsVisible = true,
            IsOpen = true,
            MaxPlayers = 20
        };
        PhotonNetwork.CreateRoom("Fight lol", roomOps);
    }

    public override void OnCreateRoomFailed(short returnCode, string message)
    {
        Debug.LogError("Mission failed!");
    }

    public override void OnJoinedRoom()
    {
        Debug.LogWarning("Joined room!");
        PhotonNetwork.LoadLevel(1);
        PhotonNetwork.Instantiate("Bullet", default(Vector3), default(Quaternion), 0, null);
    }```
#

Im 100 sure we are connected cuz the spawning bullet worked

#

I also added PhotonView component to my character

#

And Photonview Transform

#

What did i do wrong?

wicked marlin
#

How are you spawning the players themselves?

#

The prefab that is the player also needs to be PhotonNetwork.Instantiate 'd

weak plinth
#

ooooooooh

#

Ok ik what i did wrong

#

Thanks

wicked marlin
#

np

weak plinth
#

Btw

#

One more questions

#

If i spawn them like that

#

Will the Photonview Transform work directly?

wicked marlin
#

Yes, it should. I think that's the way it is intended to be used.

weak plinth
#

Ok

#

And another one lmao

#

When i spawn the players

#

And another player joins after i spawned them

#

Will he see the objects?

wicked marlin
#

Yes, as along as you are PhotonNetwork.Instantiate the player prefab, and that prefab has a PhotonView (with position and rotation checked) then movements of the gameobject will be updated over the network.

weak plinth
#

Sorry for that many question, new to photon

wicked marlin
#

No problem. I used it for the first time last year.

jade glacier
#

I would not instantiate bullets. Those typically are deterministic events, not net objects.

weak plinth
#

No i wont use that command

#

I was only testing it

#

To see in the editor

#

If the bullet spawned

#

By the other client

#

That was only to test

#

@wicked marlin

#

Something

#

Do i have to put the PhotonView component on the childeren too

#

If they got the if (!photonView.IsMine) return; in their script

#

cuz

wicked marlin
#

PhotonView can go on the parent only.

weak plinth
#

Ok

wicked marlin
#

I'd step through that

weak plinth
#

But why m i getting these errors

wicked marlin
#

I think you just have a prefab that's not set or some object couldn't be found. What do those lines of code look like?

weak plinth
#

Yeah when i dubble click on the error it shows me the photonView.isMine line

wicked marlin
#

What does line 18 of GunManager.cs have?

weak plinth
#

if (!photonView.IsMine) return;

#

See this

#

Same in here

wicked marlin
#

Where do you set photonView?

weak plinth
#

I thought it was set already

wicked marlin
#

Does the object that script is on have a photonView?

weak plinth
#

Ohhh

#

Maybe i have to get it from the parent

#

I bet

#

Yep, i think so

wicked marlin
#

Oh, I see. Yes, you probably just need to get the component from the parent.

weak plinth
#

This should work i guess

#

Worked!

#

Now i will try to play multiplayer

#

MY EYES ARE GONE

#

Nvm they were on an ignored layer lmao

harsh dew
#

lol

weak plinth
#

@wicked marlin Could you help me again

#

The local rotation and local position for the children do not work

#

I mean update

#

For others

wicked marlin
#

Sorry, I stepped away for a few minutes.

#

Add a photonView to the children that need to be updated. If their position is relative to parent, you may be able to uncheck location and sync just rotation. But try it with both (the default) first.

weak plinth
#

@wicked marlin I added the component to my gun

#

Still doesnt work

#

Ignore the color, didnt fix that yet

#

Thats how it should look:

wicked marlin
#

Is the gun a child of the player object?

weak plinth
#

Of the camera

#

Wait

#

Oh god im stupid

wicked marlin
#

ha

weak plinth
#

Oh wait

#

Nvm

#

Im not

#

I only disabled the camera component

#

Not the gameobject

#

So i should still get the camera rotation

#

Its not only the camera

#

The eyes too

#

The eyes are the component of the player

#

i mean children

wicked marlin
#

The gun has to be a child of the player prefab that is being instantiated with PhotonNetwork.Instantiate if the gun doesn't rotate or anything, then it should not need it's own photonview

#

but the gun must be part of the player prefab

weak plinth
#

Wait

#

Big brain

#

For a sec

#

Wait

wicked marlin
#

?

weak plinth
#

I have to put the photon viewer

#

On the camera

#

For the gun to rotate

#

Cuz the gun is a child of the camera

#

Big brain

#

I think

#

Lmao

wicked marlin
#

Unrelated problem: Make sure that if you put the camera on the player prefab it is disabled on awake or start if !photonView.isMine... you don't need more than one active camera in the scene

#

You want to do call and you can screen share?

weak plinth
#

Im only disabling the component

#

Not the whole camera object

#

We can still get its rotation

#

I never disabled the transform

wicked marlin
#

hrmm, yea.

#

If the gun has it's own photonView, and the rotation is checked, it should be syncing that with other players

weak plinth
#

I will try

#

Works very bad

#

It should look like this

#

I will look at the internet

drifting ridge
#

In pun2, the doc says playerlist are sorted

#

How is it sorted?

#

Based on ascending actor number?

jade glacier
#

I would assume, but not sure

weak plinth
#

funny eyes

weak plinth
#

Guys

#

Do you know how to sync the children of the player chatacter

high night
#

@weak plinth If you want to just rotate gun of the character, just sync the character's look input

#

And apply it on the other side

weak plinth
#

???

#

@high night tell me how

high night
#

lookvector, movevector
your character should be controlled by two vectors
@weak plinth

#

maybe some bools too : attack, jump, etc

#

if it's local player, you determine the inputs from keyboard/mouse and send them in stream
if it's not a local player, you get the inputs from stream

#

@weak plinth
I used to sync inputs for all visual stuff on characters

#

It will also sync your animator pretty good in most of the cases if you have animation

vernal remnant
#

is netcode and transport both separate networking layers or do I need both, or just one? quick glance at netcode suggests its a server authoritative layer which I want

#

well, a server model which id assume as authoritative while the transport is used for the FPS stuff so a more peer session based

white walrus
#

HI all, I'm new to PUN2, I was just fooling around but I tested calling PhotonNetwork.JoinRandomRoom (and skipping the call to PhotonNetwork.ConnectUsingSettings), which threw an error message
*JoinRandomRoom failed. Client is on MasterServer (must be Master Server for matchmaking) but not ready for operations (State: PeerCreated). Wait for callback: OnJoinedLobby or OnConnectedToMaster.
*

Question is - Error message says Client is on MasterServer... this is a little confusing, How can i be on the master server when i have not even connected, e.g using ConnectUsingSettings() ?

jade glacier
#

Why are you skipping connect using settings?

near cairn
#
    [PunRPC]
    void damage(float amount){
        RaycastHit shotHit;
        if (Physics.Raycast (new Ray (transform.position, cam.transform.forward), out shotHit, 100)) {
            shotHit.collider.gameObject.GetComponent<life> ().hp -= amount;
        }
    }

i mean it speaks for itself. when this method is called the error shown here is returned, and well the hp is not subtracted(im not sure if it is because of the error or because of me really at this point).

#

im not even sure if the content really works when this error is returned

weak lava
#

How do you call that rpc?

near cairn
#

when i press a key

#

a mouse button to be more specific

weak lava
#

Show me the code u calling

near cairn
#
                if (Input.GetMouseButton (0)) {
                    currentTime = timeToShoot; // irrelevant 
                    pv.RPC ("pAnim", RpcTarget.AllBuffered, "shot"); // irrelevant 
                    pv.RPC ("damage", RpcTarget.AllBuffered, 1);
                }
#

was it because i forgot the f?

weak lava
#

No, I thought of different parameters. Is the photonview from a parent gameobject or is the photonview on the same as the script the code is from?

near cairn
#

same as the script's code is from

weak lava
#

Mh did you tried putting f behind the number? I don't think thats a problem but a try^^

near cairn
#

.

#

it was because i forgot the f

weak lava
#

Uf ok

wet meadow
#

How much refresh rate is good for server?

mellow beacon
#

Less as possible

wet meadow
#

15 FPS ish?

mellow beacon
#

*ticks

#

Depends on your game and budget

wet meadow
#

Suppose I got 1000+ unit RTS game

#

or more

#

how to handle that?

mellow beacon
#

Big question

wet meadow
#

Probably even more

mellow beacon
#

Not sure what is the approach to scale this

wet meadow
#

Any solution to limit bandwidth?

mellow beacon
#

Compression

wet meadow
#

Suppose using some occlusion trick to can minimize it

#

like not getting datas which aren't in screen

mellow beacon
#

That will help a lot yes

wet meadow
#

what if my screen have more unit?

mellow beacon
#

Epic does this on fortnite

wet meadow
#

For RTS it's not impossible to have 1000+ unit in my screen

#

how to handle that?

#

Non-static object side worries me

#

Also RAM side is something to consider

mellow beacon
#

You only replicate state changes

#

And resolve them on your client

#
  • compression
#
  • data relevancy based on your viewport
#

Will help

#

But you probably can’t do that on all your systems

wet meadow
#

we can resolve stuffs to the point like ordering point A to B

#

then just use delta time/time to get the pos in real time

#

if we do that physics side worries me a bit

#

will server and client match the time properly or not

mellow beacon
#

Not perfectly

wet meadow
#

15 FPS won't look good tho which is running on server

#

while real game is 60 fps

mellow beacon
#

You don’t lock your fps on the client

#

That is the worst thing to do

#

You just set a tick rate to your server

#

That handle data replication

#

And input

#

Then you resolve the state changes on your client

#

Your server doesn’t need to run at the same rate as the client

#

And yeah it’s not perfect

wet meadow
#

Does game cause problem when going more than 60 fps?

mellow beacon
#

I can’t answer that

wet meadow
#

As far as I know animation and render side can be smooth but the thing that worries me most is physics and network side

gleaming prawn
#

RTS are done with determinism

#

You only send player inputs, tied.to a fixed tick rate.

#

Almost all RTS are done like this, you do not send game state at all

#

You need a deterministic simulation.

#

One rare exception is planet annihilation, which uses a custom method they call curves

#

You will not be able.to write a proper RTS with 1000s of units using unitys current netcode...

wet meadow
#

Possible to do with "custom" netcode?

#

Heard determinism(another name for lockstep simulation?) has desync and a bit too much strict?

gleaming prawn
#

has desync?

#

I mean, if you know what you are doing, determinism IS the way to go.

#

And also gives you a whole lot of features out of the box...

#

Lockstep simulation is ONE type of simulation that requires determinism (so it's not that determinism is another name - lockstep is one way of using determinism to achieve synchronicity).

#

But you also have deterministic predict/rollback, which gamers and press call Rollback Netcode

  • and both lockstep and predict/rollback can be server-mediated, so you avoid the most common issues with pure P2P lockstep.
#

If you want to do an proper RTS, the way to go is to use determinism... 99% of them do this... As I said, there are a few (very few) exceptions.

#

Most of the famous RTS that I know of are all lockstep simulations (RTSs do not use predict/rollback)

#

There's a whole world around determinism that a lot of people is unaware of. I attribute this due to two main factors:

  • prevalence of the FPS genre in popular games, and that led to the development of the state-transfer strategies commonly associated as "netcode",
  • lockstepping (the first original strategy involving determinism) does not work for action games.
#

But... It really depends on what you want to do...

#

You can (probably) develop a super neat custom solution (like the one I mentioned: planet annihilation chrono-cam curves model), but that would take you a LOOOOG time...:)

wet meadow
#

planet annihilation isn't deterministic? Well first time hearing about this deterministic model...

gleaming prawn
#

Planet annihilation is NOT, AFAIK

#

Pretta much all other are...

#

Starcraft (1 and 2) is deterministic (so it is heroes of the storm)

#

LOL (not an RTS though) is determinsitic on server (for it's advantages like storing replays for auditing, etc), but uses a custom state transfer method for the clients

#

But LOL is not an RTS, as said.

#

Almost all fighting games that have a (good) online netcode are deterministic

#

GGPO is the most common (very basic) predict/rollback base library for p2p 1v1 games.

#

As I said, there's a whole world around determinism... Although I do not have confirmation of this, AFAIK, racing games are also another common genre in that determinism is used (requires confirmation).

wet meadow
#

Can it handle 1000+ units? Or more?

#

How much pressure a server can take?

#

1000+ units and background actions are going on...

#

Will it be tooo much to handle?

gleaming prawn
#

What is IT?

#

🙂