#archived-networking
1 messages ยท Page 90 of 1
i mean in my status packet, i'm passing the Xmove and Ymove values which are the input values and also the localPosition x, y values of the gameobject.
id just send the position
Isn't a way to fix physics errors?
ok, but if i send the position, i'll have to trust my packet speed for that?
?
Previously i was drastically assigning the position, you sayed
what should i do instead?
what's lerping?
I passed the force values instead and used the same character controller methods on the opponent
what if tot seconds i update the gameobject position with those values?
and keep moving the character with physics
seem it would work too
but on the client, it would make alot of calculation
lets say you have 100 player
they all doing physics
instead of just lerping from a to b
depend of the game and all really
So if i take the previous x, y position from the previous packet, and update when a new status arrives, by lerping with new and previous points and delaying with 16 ms , i should get a smooth movement?
i dont know how to do the math
yeah but calculating the lerp with packets and all its complicated stuff
idk how to fix it rly
{
public bool MoveDir = false;
public float MoveSpeed;
public float DestroyTime;
public float BulletDamage;
private void Awake()
{
StartCoroutine("DestroyByTime");
}
IEnumerator DestroyByTime()
{
yield return new WaitForSeconds(DestroyTime);
this.GetComponent<PhotonView>().RPC("DestroyObject", PhotonTargets.AllBuffered);
}
[PunRPC]
public void ChangeDir_left()
{
MoveDir = true;
}
[PunRPC]
public void DestroyObject()
{
Destroy(this.gameObject);
}
private void Update()
{
if (!MoveDir)
transform.Translate(Vector3.right * MoveSpeed * Time.deltaTime);
else
transform.Translate(Vector3.left * MoveSpeed * Time.deltaTime);
}
private void OnTriggerEnter(Collider collision)
{
if (!photonView.isMine)
return;
PhotonView target = collision.gameObject.GetComponent<PhotonView>();
if(target != null && (!target.isMine || target.isSceneView))
{
if(target.tag == "Player")
{
target.RPC("ReduceHealth", PhotonTargets.AllBuffered, BulletDamage);
}
this.GetComponent<PhotonView>().RPC("DestroyObject", PhotonTargets.AllBuffered);
}
}
}
there is code
you dont need to observe that
@gleaming prawn do you happen to know if it will it be difficult to migrate to fusion from bolt/pun?
Kio
trying to figure out if it is worth setting up some basic networking right now with bolt or just wait a bit
ok
ye but i dont have this OnPhotonSerializeView on my bullet script
hehe
if i delete it from photon view i got error about OnPhotonSerializeView
and its still giving that error?
there must be another
wait a sec
another PhotonView?
is it observing the bullet script too
for (float i = 0; i <= 1; i += 0.2f * Time.deltaTime)
{
gameObject.transform.localPosition = new Vector3( Mathf.Lerp( oldStatus.positionX,
status.positionX, i), Mathf.Lerp(oldStatus.positionY, status.positionY, i), 0);
}
``` @grim violet i'm trying with this...+
maybe you have to add deltatime in between
i dont know really
math aint my best
id ask on general code maybe
ok
@silent zinc sounds like you need to implement some playout delay. To get smooth motion, you need to interpolate between physics frames. To interpolate you need information about more than one frame.
it's like buffering a youtube video. Except in this case you want a buffer that's large enough to ensure smooth gameplay but small enough not to affect player decisions
the buffer being input or state
i have an object in the scene with a photon view component but how do i make it so there is only one of them and not an instance of it per client
if its in the scene people will only have 1 of them
if each player instantiate it once scene is loaded thought, not the same
each client will have one tho from what it seems like
no its in the scene with a photonview component and each player has their own instance of it from what it seems like
scene object are controlled by masterclient
well there is code that is being repeated and i dont understand why
the only way for that to happen is if there were two of said object
when there is one player offline it works fine but when two players are instantiated on the network this code that the object uses happens twice
it spawns double the enemies
probably a code problem then, if you look in hierarchy do you see the object twice?
let me build and run real quick
according to the scene there is only one gamemanger object
which is the one im talkign about
but that same gamemanager only has a line repeated once GameObject gO = PhotonNetwork.Instantiate("Models/Player/Player", playerSpawns[0].transform.position, playerSpawns[0].transform.rotation); playerList.Add(gO);
but two players spawn, which it should do but I dont see how two players spawn unless this is running twice aka there are two gameManager objects
debug.log see if it run twice
you will see the stack trace whre its coming from
well i see one issue here,
i wouldnt surprised its something with gamemanager being a singleton and being ghosted in the back
whenever an enemy spawns i have a debug.log("enemy spawned") which that only has 1 log
but two enemies spawn so how is that even happening
okay im using the gamemanager object to organize and store data and spawn enemies and stuff like that, should i just have something like if(!photonView.IsMasterClient) Destroy(gameObject)
because there is a lot of data being changed at runtime and it seems like only one player would need to keep track of it all
you should use the master client to spawn and destroy object in the scene
that player that keep track of all is the masterclient
exactly so I wouldn't even need it for the other clients right?
should i just destroy it?
you shouldnt spawn it in first place
its not spawned
destroy what
the gamemanager
its in the scene at the start of the game with photonview
i mean you dont only have spawner in there
yea i have a lot of gamelogic that each client would need to referenced at runtime
i dont know how you setup your game
so destroying it wouldnt work actually
but gamemanager clearly shouldnt have a photonview on it
but its like there are seperate instances of the gamemanger
unless its your spawner too
its the spawner
it keeps track of the game nothing to do with the individual player stats
like starting and ending rounds and such
and spawning enemies
well everything about the spawner should have the mention "if (im the masterclient) then.."
so only the master will spawn it
okay il ltry that
@gleaming prawn I finally built my client reconciliation for the prediction system and it's working great, but directly after the reconciliation happens, is it normal to notice a very tiny jitter?
I havent built the interpolation in yet
I suppose the jitter is just caused by the different position being applied and rebuilt
@grim violet it works but a lot of the variables arent being updated properly for the gamemanger, the masterclient is setting the variables properly but on the other clients side its not updated.
you have to change the value on other client either by sending an rpc, a raiseevent, or by observing the component being changed and streaming the variables
okay thanks man anything i want tracked across the network ill use a rpc
do i have to make a new function with an rpc or can i do it in a line? @grim violet
alright thanks for the help
@slow monolith yes you need to interpolate slightly
Perfect thanks
@gleaming prawn I should pause the fixedupdate auto simulation while im doing my re-simulation right?
I think you might be falling into a trap in how you are thinking about time in game dev.
Unless you are multi-threading here (which would be a bad idea), there is no "time" passing.
Well I paused the physics auto simulation and I'm just running physics.simulate at the end of every fixed update
again, you are pausing something that isn't moving.
When you run your game logic or whatever, the game isn't "running" in the background
My re-simulation is done in a single Update() frame
multiple fixedupdates can occur during a single update frame
you can run your sim 1 million times, and to your game no time has passed. All you will be doing is making your game hang on that frame for a few minutes.
alright
Just like if you run a for loop...
everything else is stopped. It isn't asyncronous.
{
if (PerformSimulation == false)
{
Physics.Simulate(0.02f);
}
}```
So this is wrong
?
Your only concern is if your resim takes so long that it causes a frame rate drop, and makes your game hang.
Nothing wrong there
alright
But why are you disabling that simulate?
I disabled auto simulation, and I manually call simulate at the end of every fixedupdate
I think you are doing that because you think you have to "pause" things while you resim... which is the error in thinking
Disabling autsimulate is good, and normal yeah
When you rerun your simulation for whatever reason, that shouldn't be making FixedUpdate fire
Correct but
fixedupdate runs regardless of what update() is doing
so fixedupdate CAN be firing while my simulation is running
Again, you are talking as if this is asyncronous
yeah I think im confused
It cannot
this is single threaded
Fixed will not run again until you release all control
If you have a method that is rerunning your simulation, that all happens before Unity gets control back.
{
Physics.Simulate(0.02f);
}``` So remove this if statement?
It is meaningless, if it is for what you are talking about.
alright
Fixed will not run again while you are still looping through any code
Make sure you understand why, this is the same trap people fall into when they try to use Coroutines and it never works like they think.
This is all on a single thread. Time doesn't "pass" with a game engine... time is accumulated, and caught up when control is passed to the timing mechanism (in this case FixedUpdate and Update)
If your resim takes 3 seconds to finish... nothing will happen and your game will freeze for 3 seconds....
and when Unity gets control again, it will have to run a ton of Update and FixedUpdates until it is caught up on time.
FixedUpdate DOES NOT happen in realtime.
Yeah I suppose that makes more sense
When Unity gets control after a screen refresh and starts a new frame, it sees how much CPU time has passed since it last rendered a frame... it then divides that by fixedDeltaTime to see how many "ticks" worth of time has passed since it last ran....
It then calls FixedUpdate that many times, and runs PhysX that many times.
THEN it calls Update()
Then LateUpdates.... then it renders the results to the screen...
My next question: Unity is non deterministic and my player moves with physics on both the server and client
however, the movements are basically the same, within a thousandth of a decimal
You will constantly be fighting with desyncs
is this only because im running on the same hardware?
desync isnt a problem
Will other hardware have more desync problems though?
Correct
but I was under the impression that the physics movements would vary wildly
but that's not happening
they're fairly consistant between server/client without re-syncing them
wildly isn't the case for a lot of things. But the butterfly effect eventually will come into effect if they aren't the same deterministically
alright
that and non-deterministic actions by players
If two players bump into one another, a desync has to occur
All player actions are going to throw chaos into the system
Last question
if I'm re-simulating my player on clientside and say I have another object, a cube with a rigidbody falling
and I dont need to do resimulation on that cube, only the main player
Do I just set the cube to kinematic
then back to dynamic after the simulation?
If you aren't deterministic, that is pretty normal to only resimulate the things that need to get into closer sync.
Redoing the entire simulation for all objects is kind of pointless if you aren't deterministic
Correct
which is why im only doing it for my player
but will I need to re-apply the velocity to the cube after I make it dynamic again?
Typically for what you are doing, you are just trying to get the player into closer agreement than it was a moment ago.
Yeah but the problem is, physics.simulate simulates ALL objects
I only need it to do one
Make a separate scene
For my experiments and others I have heard of as well, make a scratchpad scene
And populate it with simple versions of your game objects from the real scene... just colliders and empty gameobjects...
and you enable and move those around as needed, if you are doing small isolated resims.
Won't that eat up performance?
A lot less than resumulating your entire scene just to get a players movement closer to agreement with the server.
There is no one answer. Depends on what your simulation consists of.
And what you are trying to get out of your resim.
I think 2d has an option to only simulate a specific rigidbody in a scene
not sure why 3d doesnt have that yet
If two players bump into each other.. you won't want to resimulate 50000 objects just to get those two into sync.
If this were deterministic you would have to.
But you are not.
ok
You might consider not using PhysX for your player controllers
Whats my other option?
If your code isn't PhysX simulation, then you can just rerun your own simulation code.
The other option is your own more lightweight physics specific to your exact objects needs
a CC yes
That is what Bolt does, it has its own character controllers for people to use with their own simulation code, which allows for it to do quick rewinds and such.
Though that choice was because PhysX in Unity back then was pretty restrictive.
I was actually wondering how they did it before physics.simulate existed
that sounds like a lot of work
Major titles don't rely on PhysX the way hobbyists do
For real shooters, the game devs manhandle their player movement code
Only problem is, I need cars, and the wheel colliders only work with a rigidbody
You are limited to how much you can make PhysX bend then yeah
RocketLeague had to invent a bunch of their own tech for networking for a reason
Do you know if unity has plans to use physics.simulate on a single rigidbody?
I don't know of any such plans, but I don't really follow them that closely.
ok
I would be surprised if the PhysX api in Unity gets any major updates in the future
That particular request might come from the MLAPI team when they try to make server authority work. So maybe it could happen?
It is a very specific thing to a very specific networking problem though
ah, that would be interesting
yeah, and you'd still need to do the cache clear workaround to make simulations similar across clients
The ability to simulate only specific objects against all static objects... is not something people ask for every day.
PhysX is just not made for that.
We are brute forcing a lot of this for Fusion... which is the only real answer. There is no elegant fix.
I just think unity has been alive for too long to have this little support for multiplayer games
maybe im just picky
Networked games is not in their DNA
Unity came from making single player games that run everywhere. That was always the focus.
Rust and tarkov are so smooth with multiplayer though
at least from what I've seen
I suppose they don't have a lot of physics going on though
I did some testing and it seems that setting other rigidbodies to kinematic while re-simulating the player works out pretty good
Please let me know if this is going to cause any major problems in the future
Hi, i'm using mirror and want to pickup or drop items within the world. What is the best way to archieve this?
Hi all this is my first attempt on multiplayer game and I know multiplayer games mostly depends on networking so what should I learn first like different networking solutions available for unity or the networking basics?
Any one have tutorial about creating a multiplayer game? I know programming, don't have any fraid to get my hand on dirty but i'm difficulty find good way to implement multiplayer. The game doesn't matter, only want to know what is the best way..
@gleaming prawn When you're next online, can you give me a quick example on how you would interpolate the position before and after the simulation? I'm having difficulties, mainly because the position is always moving.
Do you have a tick system?
But if you just copy the Transform data from the simulation (that is recnciliated by server to the Unity Transform using a bit of Lerp this already helps)
This assumes you do not set data directly to Transforms
First, to make sure I'm even re-simulating correctly, directly after the resim happens, there should be a slight jitter right? Looks like it basically skipped a frame?
Also I'm not sure what you mean by server reconciliation, isn't reconciliation only supposed to happen on the client?
By tick system, do you mean the timestamps sent with every frame information? Pretty new to the terminology of all of this
To be able to do reconciliation you need to make your simulation tick based (ticks/frames counted) that you manage yourself
Because the lib you are using is NOT tick based as far as I know
Without a tick system, the reconciliation is complicated
I'm not using a library, I'm writing everything from the ground up
How do you RE-apply inputs when you receive a server snapshot?
when the input goes to server, it must go with a tick number (to be applied there when that time comes).
When I re-sync the client, server sends last valid input, along with the sequence number that belongs to the frame
client keeps all packet info
I think thats what you mean by ticks right
Then when server DATA (snapshots/state) come down, they must be flagged with a tick
THEN you can apply that, recover ALL inputs queded (in client) with a tick after that one, then RE-simulate those for the local player (this is the reconciliation)
Yep i'm doing that im pretty sure
If this is not ALIGNED to a clock, it will jitter
Ok thats the part where im confused
You need to have your clients to follow the server clock, etc
It's a lot of concepts together
I again suggest you watch FHolm's streams
He's teaching these subjects almost everyday now
With open source code examples on his github
Just to re-confirm, when the client receives the packet from the server, it contains the last valid position that the server has kept, along with a distinct ID mapped to it. Client goes back to this position then re-runs all client-side inputs which occurred after that point
I don't see how the server clock would come into play
Unless that's what you mean by it
But then I have that microjitter which sometimes occurs after the re-simulation is done. Is that just unity's non deterministic characteristics?
I'm fairly certain the jitter is just caused by me not interpolating properly
If not though, then ill go and watch the videos. I'm just not a fan of lectures, would rather be outright told what the issue is so I can google and skim through articles
I'm guessing this channel does not cover WebGL deployment?
@slow monolith do you modify the Unity Transform directly when doing server reconciliation?
Normally you should use a separate buffer for the networked data, and THAT is where you perform reconciliation... Then you interpolate that to the Transform, etc
I'm not modifying any transforms for the reconciliation
my main character is physics based
so I call physics.simulate
unless I misunderstood your question
But yeah to answer your question, the physics is directly being modified during reconciliation
for loop () {
gameobject.velocity = stuff[i];
physics.simulate(0.02f);
}
I also moved it from update() to lateupdate() and like half of the jitter is gone
still some though, I just need to figure out how to interpolate it properly
Sorry for the half assed example, extremely tired and going to bed
You have to be modifying the transform somehow on server reconciliation
You need a separate storage of the vector and quaternion
If you did not understand the question, seems like you are modifying directly, which means you have a lot more to go
Again, itโs a bit pointless to try to โfixโ advanced errors on something that does not have the basics done right yet
I again suggest you consider watching fholm videos. Iโll refrain from commenting again, as itโs not leading anywhere really
any idea on why this isn't executing? Using photon
what is not executing, the OnConnectedToMaster? if that is you need to extend your class with MonoBehaviourPunCallbacks
not sure thats where you set your nickname either
i think it should be before not quite sure
what on mirro, i need give to my friend for join to my game ?
bsc i can run build and game from unity and then i have multiplayer
but if some one else want join he cant , i send him my ip adres etc
i.gameObject.GetComponent<PlayerMovement>().playerMesh.SetActive(true); i wouldnt have to specify this as a rpc if the gameObject i has a photonview on it right?
you have to use the Invoke() method. Be sure to read the manual for RPCs, you wont guess it on your own. @sly fable
For photon, can I only use PUN or use any of their photon products?
I don't understand the question @misty scarab
Photon is a collection of services and software
@jade glacier okay, even regarding objects with a photonview?
I don't get the question sorry
Photon offers multiple services, like PUN or bolt. I'm asking if PUN is the only one that can be used with unity
Does anyone know how I would add the ability for a game to have multiple rooms/scenes (like Club Penguin). I am currently using Mirror and have it working with one scene but I would like to have two rooms for a player to join and see separate people
Should I be doing my client reconciliation re-simulation in an entirely different scene?
I tried using physics.simulate on my main scene to rebuild the movement, and its jittering awfully
I tried it about 20 different ways, super lost
On the jitter, are you buffering the arriving packets?
Not sure what you mean by that
I'm building my own solution from the ground up with literally no prior experience
I even tried it without a network entirely. As an example, I just got the last 5 predicted movements from my array, went back to the first position of those 5, then just re-simulated it with physics.simulate
Not sure if it applies to the issue you're currently having, but packets don't travel along a single stable route when sent across the internet. Some will get dropped, some will arrive in the wrong order, some might even get duplicated. You might transmit them at a precise interval, but that doesn't mean they arrive at the destination still nicely, evenly spaced.
So normally, you'll have an array/buffer/queue on the recipient that collects several packets before removing them at your fixed timestamp rate in an evenly spaced way.
Not doing this is will cause jitter across a network, but if it's happening locally, there might be another issue.
Yeah as I said, I tried it even without a network
took the last 5 predicted movements, went to the first value, teleported my player to that position
and simulated them all again
my rigidbody stutters whenever that happens
I tried that like 20 different ways, still jittered whenever it happened
idk, I've never tried manually updating the physics simulation
Are you still using a fixed timestep? Unity says the simulation is nondeterministic with a variable delta time. https://docs.unity3d.com/ScriptReference/Physics.Simulate.html
I turned off autosim and manually called physics.simulation at the end of every fixed update
Are you collecting your input in FixedUpdate()?
update
{
RigidBody.position = (PastNetworkingStuffClass.NetworkingPlayerPosition[PastNetworkingStuffClass.NetworkingPlayerPosition.Count - 5]);
for (int i = PastNetworkingStuffClass.NetworkingPlayerPosition.Count - 5; i < PastNetworkingStuffClass.NetworkingPlayerPosition.Count; i++)
{
RigidBody.velocity = PastNetworkingStuffClass.NetworkingPlayerVelocity[i] * Speed;
Physics.Simulate(0.02f);
}
PerformSimulation = false;
}```
This is basically what my non networking resim looks like
just grabs the values from the prediction array
thats in update()
the stutter is pretty awful and really noticeable
only happens once per PerformSimulation
Photon offers multiple services, like PUN or bolt. I'm asking if PUN is the only one that can be used with unity
@misty scarab
Can someone help me
But then joy I had another idea
to only re-simulate an invisible rigidbody
and then have my player lerp to his positoin
I did that by making my main character kinematic while running the re-sim on the invisible character
the stutter was still there
I dunno, my guess is that the problem is in this mixing and matching FixedUpdate() and Update(). You might be stepping the physics simulation too slowly or your input might not be sync'd properly when you go to re-sim, idk.
The "fixed" in FixedUpdate means the simulation is integrated by a fixed timestep, not that it has a tick rate of that timestep. In order to deal with a varying render framerate, the physics simulation accumulates a frametime "budget" and steps N times in a row (N = budget / dt). So depending on your framerate, you can have bursts of several FixedUpdate() calls in between Update() calls or none at all.
At least, that's the normal, automatic behavior.
I was under the impression that I could step the physics anywhere at any time
physics.simulate also does not call fixedupdate
You can call simulate whenever you want yes. I have no idea what you have going on, but if you are getting massive jitter in what you are describing, you just have a serious flaw in your resim.
Minor jitter can be expected, since you are in fact making small corrections. But what you are describing sounds like just a bug in your code.
{
RigidBody.isKinematic = true;
for (int i = PastNetworkingStuffClass.NetworkingPlayerPosition.Count - 5; i < PastNetworkingStuffClass.NetworkingPlayerPosition.Count; i++)
{
Physics.Simulate(0.02f);
}
RigidBody.isKinematic = false;
PerformSimulation = false;
}```
This alone causes stutter
I removed all of the player movement/teleportation and made the player kinematic while re-simulating
Yeah, I'm not sure if that impression is correct. You want to step your physics forward by a fixed amount regardless (Unity's default is 20ms), but normally your render frame rate is larger than the physics timestep, so Unity will do a burst of several sim steps at once. The way you're doing it seems either variable or too slow.
so its something to do with stepping the physics engine
The major problem is that there's like 2 posts on the entire forums about physics.simulate
so like nobody has any clue whats right or wrong
yeah, cuz I don't think anyone goes messing around with manual simulation
Rust was made with unity, they have rigidbody cars
and they have perfect prediction on them
The only way they could do that is by stepping the physics engine manually when they need to resync
We mess with simulation all the time for networking.
^
Photon Fusion and Quantum are built around that.
All I can say is start VERY simple
If you say so, I wouldn't know. I figured that you'd at least want input to be sync'd at the FixedUpdate rate.
And set up a lot of debugging telemetry so you can monitor what is being done to the transform.
Cant do that with fixedupdate
Export to a csv file if need be, so you can look at the data in a spreedsheet.
I tried multiple computers, and even looked at it inside scene view instead of a camera
Input is captured in Fixed @dense hedge
and the player is visibly jerking
But that is outside of the "simulation", that is just gathering what will go INTO the simulation.
Once it is captured, the inputs become part of the permanent history.
Yeah, I mean to have it lined up with a particular tick/frame when you need to reconcile.
Resimulation is how you resync with the server, when the server gives different state results than the client predicted.
I'm aware of the fundamentals. I just don't know how you'd control the simulation in Unity with code in Update()
You gather inputs on FixedUpdate #300 or whatever.. and feed those into the simulation to get the state for frame #300
@dense hedge The idea is to re-simulate whatever you need, in one single frame
If the client is on 307, and hears back from the server the results it got for 300... and they disagreed... the client resets the objects in question to what the server said they should have been for frame 300... and then reapplies 301, 302, 303, 304, 305, 306 and 307 inputs.
All of those reapplication of inputs involve calling .Simulate
yeah, I was guessing that the jitter was possible caused by a mismatch in the simulation frames and what input was used to replay after reconciling
no mismatch at all
but idk
since the second example I gave makes jitter too
If it is major, then you have a flaw somewhere
which is the best networking solution for a 2d game ...free
If it is minor, then you are just seeing the non-deterministic nature of PhysX most likely. Hard to say without a LOT of telemetry.
{
RigidBody.isKinematic = true;
for (int i = PastNetworkingStuffClass.NetworkingPlayerPosition.Count - 5; i < PastNetworkingStuffClass.NetworkingPlayerPosition.Count; i++)
{
Physics.Simulate(0.02f);
}
RigidBody.isKinematic = false;
PerformSimulation = false;
}```
but then we have this, as I've posted before
no movement, no teleportation happening on the player
just making him kinematic, running physics simulate, then making him dynamic again
causes jitter whenever it's called
Why make it kinematic if you are trying to simulate?
kinematic by definition means "don't simulate me"
I am not following what you are doing at all then.
If your main simulation is non-kinematic... then your resim needs to be non-kinematic.
Otherwise there is no point in resimming.
After the re-simulation happens, if you're doing it on your main player, the player is obviously going to end up in a different spot
he's going to teleport
causing a jitter
so you have to lerp the position
I wouldn't touch lerping yet
but the main character keeps moving, so that's going to be hard to lerp, since you need to lerp over several frames
Avoid all interpolation when getting stuff working
You want to see the slideshow without anything being glossed over by questionable interpolation code.
Wel the re-sim is happening all in one frame
Disable interpolation on your RBs as well.
You are mixing all kinds of stuff together here.
Remove all interpolation while you work our your logic.
You aren't going for smooth yet, you are going for not borked.
You are mixing kinematic in with resim... so you are already borked. Get that sorted or you are just trying to hide your mistakes.
Kinematic was only for the second experiment I made
I've tried like 20 different ways
I have no way to guess which we are talking about atm, sorry.
Do the basics
Reset the objects to the server state... resimulate X steps to get back to current... monitor the telemetry to see where the results deviate from the servers results.
My experiment doesn't include a server right now
That should get you very close to in sync for most object types. You are going to have errors though.
I am beyond confused then
What are you resimulating if you have no server state?
So for right now, I have NO server or networking involved, just so I don't have any networking variables that could fuck up my experiment
let me explain
I save all user inputs, otherwise known as the predicted states
during my experiment, I grab the last FIVE in the array
You are just trying to see if you can rewind and get the same results twice?
In a sense yes, I also enabled enhanced deterministim in unity's settings
and it's still jittery
your inputs are not predicted states btw, that is why you are being confusing.
your input history is your input history. Your state history is your state history.
Nothing is predicted, because you have no server that is the "actual" final word.
Whenever the player moves, inside fixed update, I have it saved to an array
You are testing to see how messed up things get if you try to reset objects in PhysX and apply the same inputs.
The answer is that they will not be deterministic
Because PhysX is not stateless.
But the next problem is, how would I smoothly interpolate it
Moving objects to where they were and resetting their velocity/angvel ... will still leave the cache untouched.
Typically once you resim, you know the state that you just showed the gamer last Update(), and you know what they should have seen... so you will lerp in that direction. The logic involved varies based on how you want to try and make that happen.
But that should be cosmetic only. The tick state results are the only hard reality.
I just dont understand how I would lerp to a constantly changing value
eg: the player's next predicted inputs
obviously I cant lerp inside a single frame
Nope, you have to nudge the object toward its new target. Rather than lerping between your previous snapshot and the current snapshot... you lerp between the previous WRONG snapshot and the current snapshot.
Your resimulation tells you the most currently correct target
So I have to re-simulate, then revert the player back to his past position, then lerp to whatever position the re-simulation gave me?
I can't speak to that. I would never resimulate in my actual scene like that.
Would you do your re-simulation in a different scene?
Ive heard some people doing that
But if you are using one scene, you will want to record what you just showed the user of course.
Or how else would you do any kind of lerping if you no longer have any information about how things were?
At the AAA level you would never have one simulation trying to do all of that.
So the answer is to use a second scene, running it's own physics?
It is AN answer. There is no "THE" answer, because PhysX is just not meant for this.
So you are just picking the least offensive hack.
yeah
On this second scene, would I ONLY run the physics when I need to reconciliate?
to save cpu?
2nd question: It would be a lot easier if I didn't use a rigidbody for this, and used, for say a character controller or something?
You would enable the objects involved (leave the static scene objects always enabled).. set the RBs velocities and positions.. resimulate... then record the pos/rot/vel/angvel - that is the new resimulated tick state.
alright
That is still just a part of it, you have to sort out how you are interpolating down the line. Typically you have a target snapshot you are lerping everything toward in Update().
So on my main scene, when I need to re-sim, should I execute blocking code in update(), do the re-sim on my other scene, grab the values back, and then apply it, all in a single frame?
And then last question, when applying the values to my main scene, should I use rigidbody.position or rigidbody.transform.position
I think transform is the correct answer, just need clarification on that
You still seem to be talking about this like it is multithreaded
There is nothing to block
There cannot be any Update() or FixedUpdate() calls between when you start your code segment and when you end it. The entire game logic is linear. Until you release control, nothing is happening.
That's what I mean though, to call my other scene and wait for his response after he complete's the simulation
would all be done in one frame
right?
I think emotit is confused since you're making it sound a bit like threading, where you need to wait on one thread for something to complete on another, but Update/FixedUpdate aren't like thatโone runs, then the other. Unity has a good diagram on this: https://docs.unity3d.com/Manual/ExecutionOrder.html
FixedUpdate might repeat before moving on to Update, if the physics timestep is very high compared to the framerate, but it's still sequential
Sooo to answer my question
yes, all happens in one update frame
?
I'm being annoying as fuck, I just want to make sure I'm doing this the right way before I dedicate another 20 hours to building this lmao
Also do both scenes run at the same time?
It's the other way around. The physics simulation usually steps several times because it runs too slow to be 1:1 with the rendered framerate.
It's like this (this isn't actual unity code)
budget += Time.deltaTime;
while (budget >= Time.fixedDeltaTime) {
previous_state = state;
budget -= Time.fixedDeltaTime;
physics.step(state, Time.fixedDeltaTime);
}
render_state = lerp(previous_state, state, budget/Time.fixedDeltaTime);
gfx.render(render_state);
yea, it can be either or. Mostly was just using it as an example (but I'd say you're correct that Update being faster than Fixed would be more common)
For a second scene yes
@floral turtle Actually, sorry. I think you had it right. It's late and I'm confusing myself. It's not just render time. The simulation will step several times if it has enough of a budget, which would imply that everything else is take a bit long.
ok
@jade glacier So are both of these scenes running physics at the same time? Or do I have to shut down one scene
I'm not sure how else to explain how there is no "same time"
Neither scene is doing anything until you tell it to .Simulate
but I can call physics.simulate at the same time, and theyll both respond to it
physics.simulate is just the primary scene
MyOtherScene.Simulate is how you simulate secondary scenes
Is it normal to be seeing both scenes when running the game in the editor
and can I make it only see one?
There shouldn't be anything to see in your simulation secondary scene.
If you go that route, you will want to write a way that replicates only the colliders and key components of objects
how would you hide certain ui from one player but not all?
I have a namtag above my player but Id like it so the player cant see their own nametag only everyone elses
which library?
photon
if (photonView.IsMine) HideWhateverThePlayerShouldntSeeOfThemselves()
Be sure to do the basics tutorial, it covers this specific case I think.
@jade glacier the ui is on a character with a photonview
if i disable the ui it would disable it for everyplayer right?
Not if I am understanding your question
Nothing is implicitly synced.
Do you have code that disables the UI?
Ill try it out, but i assumed since the UI element I want hidden is a child of an object with a photonview it would disable it on all screens
Still not sure what you are asking. But if the object has a PV on the root, just get that PV's IsMine to determine if the child is enabled or not.
Be sure to do the getting started tutorial. It sounds like you are making some assumptions about networking.
Hello, So I'm trying to use "Google Play Plugin for Unity" to authenticate my game with Play Store. On my mobile, it shows me the banner of Google Play, it shows my name and level, and then returns we with Cancelled. Why is this happening? I've checked quite a few articles regarding this issue, can't seem to find a fix.
any suggestions of tutorial or blog to learn mobile multiplayer networking in unity?
Dose anyone know how to connect with unity mirror to a game?
Do the samples not do that out of the box?
Are you talking to me?
Yes
oh
They don't.
You have to put a ip address in the Input field and Join the game
but I don't know what ip to put to connect with my firends
I have the game and I tested it with local host
but I can't play with my friends that are not on my wifi
As a host you would give them your public IP and make sure your port is open
How do you leave your port open
Look up port forwarding
k
You can figure out this part of the process by setting up a Minecraft server ๐
lol yea
@spring crane
I have another question. I'm following this video https://www.youtube.com/watch?v=X75GbRaGzu8 and its saying that my ip starts with 192.168.1. and I can't find a ip in my config that starts with that
Want to host your own Minecraft server, but you're confused with how to port forward? Don't worry, it's super easy. This video shows you how to allow the server through your Firewall AND port forwarding! This means that after watching this tutorial, you'll have everything done and ready!
Using an extender, or more than 1 router between you and ...
my Ipv4 address starts with 10.0
That can work too. The objective is to access your router's settings
Has anyone had any luck getting physics.simulate to work properly for client reconciliation?
Or do I need to do that in a different scene?
I get tons of jitter whenever I use physics.simulate inside my main scene
Anybody has the experience of using google services? I have a question...
I have a C# server and want to connect to a website using WebGl for multiplayer use. Would the Server work for multiplayer in WebGL build?
@thorn hornet You might get away with these if you don't take half a chat to do it. These sort of things are generally posted on collab sections, and we don't have one.
@spare locust Hosting from a WebGL build is generally a problem, but you certainly can connect to a server as you can see from most networking solutions supporting WebGL builds. WebSocket is the most common way to do it.
Did you find an answer to your question ? I used only the JavaScript SDK and there you can easily access children through their path (root/child/child). There should also be a verbose way, smthg like FirebaseReference.getChildWithKey("subObject") or close, you get the idea. Check the doc ?
If you only want to list their name, just point the Reference to the "root"/"parent" and you should be able to iterate. From memory there should be a smthg similar to a .value() to first reinterpret the DataSnapshot as a list or anything else iterable.
what networking would you guys recommend to learn first? should I learn the built in or a different one?
@vast grail Depends on what will work best for your project.
I am thinking of doing simple 2d arcade thing just so I can learn how networking works
Learning Mirror is a solid starting place to learn the basics of networking in Unity.
ok, thanks
Hey, so I have a bit of a roadblock rn. I have an object with a networkidentity and all that, and this object has children with scripts attached to them. How do I syncronise variables in these scripts across clients, if I can only have a network identity on the parent object?
this is in mirror
the way i read it from the doc, you must spawn a prefab of your gameobject with networkserver.spawn
so they gonna have the whole prefab networked with 1 identity
there a mirror discord server i think where you could get more help about it
oh ok, thanks, ill check out there, and also try that
Try 'com.unity.networking' ?
I'm at a loss at what 3rd party networking solution I should be using. Any recommendations? MLAPI does not look ready.
The critical factors I need is: cheat prevention, scalable, and doesn't require advanced networking experience to implement.
Any thoughts on Mirror vs PUN2?
The primary difference I would consider is the PUN2's peer to peer over relay setup vs Mirror's more traditional client - server setup.
I think Mirror is more secure compare to PUN2
but depending on how you implement it...
what kind of game you making
I'm making a VR game that's real time. Up to about 8 players per match is probably what I'm aiming for. Players need to see each other move around, their hand position, grabbing & moving objects.
most anti cheat solution require a server with authority, which mean advanced networking experience
there is always way to do it with p2p and all but it get complicate quick
p2p and cloud scale better than having ur own server thought, which you will need to make loadbalancing and all between your own server
Is p2p and peer to peer over relay that @spring crane mentioned the same(ish) thing?
yes
but do you need a remote server
can it be local
do you need to save stuff online?
Yeah I need to save stuff online
Sounds like client/server is what I need, and that Mirror is more robust at that, based on what you're saying
but mirror is client server on same computer (at least i think)
youll need another server online to save stuff of peoples
The server can be anywhere
with mirror?
Yes. If you couldn't move it, it would basically be peer to peer with extra steps ๐
It can run in Server, host or client mode
i thought it was server on the same as client
you need to run the unity game in order to have the server up?
yeah i just cant stick in my head having to run a game on a windows server to have my server up
lol
I found a comparison chart with PUN2 and Mirror on it. Not sure when it was last updated.
https://docs.google.com/spreadsheets/d/100vNy3grUgLV5M7rIUKUtRqO4cmTewQI8P5uwf-Qb9k/edit#gid=1672881265
Landing Page
High Level Overview of some networking frameworks available for Unity3D (WIP)
The tables in this document should provide you a high level overview of different networking frameworks available in Unity. There are side by side comparisons for High Level Frameworks, Low Level Framework...
Sounds a lot like Mirror is the way to go based on what you guys are saying.
@grim violet It's headless, so it doesn't feel that bad ๐
Population One (VR battle royale) apparently used Mirror, so thats a good sign. They needed scale, anti cheat, etc.
Thanks for help guys ๐ Gonna just get started on Mirror and see what happens.
Probably referring to ability to connect 2 clients directly to each other
ahh
Hey I am using Pun2 . When I disconnect from a Room and after that join a Room three PlayerManagers are Instantiated. Can somebody help me immediately or have I to post my code?
i dont think its related to pun but more about your class script being a singleton
show code
That's my PlayerManager Script
look what they do here in awake: https://answers.unity.com/questions/891380/unity-c-singleton.html
to prevent multiple instance to run
thank you. I think it's fixed
Now the problem is that for the other Player no PlayerManager is instantiated because the singelton script makes that only one PlayerManager can exist
Your PlayerManager should probably be able to handle more than one player
how do i do this?
Depends on what you are managing. The gist is to write logic that works with multiple instances
If you need to spawn players, spawn multiple. If you need attach data/state to each player, create a dictionary that maps data to each instance
If you need to do decisions based on a player, loop through all players.
If all logic is based on handling a collection of players, you can throw in as many players as you wish
On Mirror asset store page, they say:
Note: Mirror is based on Unity's abandoned UNET Networking system. We fixed it up and pushed it to MMO Scale.
Isn't it bad that Mirror is based on UNet? Will Mirror be unusable when UNet is gone for good?
https://assetstore.unity.com/packages/tools/network/mirror-129321
๐
Any thoughts on NormCore vs Mirror?
https://normcore.io/
NormCore doesn't seem to be trying to solve a lot more than Mirror, though it probably does have the benefit of having full time employees.
Normcore is more a competitor to pun2
Not really even close to fusion, bolt, and totally different than mirror and mlapi
Itโs relay based
pricing of normcore seem half photon too
Oh should have noticed. Was enticed by what appears to be physics rolling back gif on the site and walked out disappointed by the physics documentation ๐
How about the room hours stuff?
i dont know what that is
but there is unlimited rooms up of that
it cant be 1000 hours in a room...
and no info on the website anywhere or google
seem like a trap
No gimmicks.
roll eyes
;p
never seen a company says directly we rip people
hehe
yeah thats the only bad looking thing right now
they claim to be the best available
im gonna mail em and ask what it is
but dont provide any sort of benchmark
cant even find an email address
i guess that solve it
oh found it
ill show anwser once i get it
or if i get it
They seem like a legit company, been around for a few years I think
Read through everything, try it out
(I work for photon btw)
if i buy the 100 photon ccu for a year and the year end
im i obliged to get the 500 ccu
I donโt think so
You can renew for one more year and so on
thanks god
What it says there is: pay one time, 100ccu for 12 months
yeah but before it was one time for 100 ccu for 5 year
Yes, that was Themis deal
i thoguht it was a deal, which would make this a deal too
The old*
But you can renew it
In practice what happens is your game either works (and you go for higher tiers) or it dies in a way that you could just use 20 free to leave it around
Very very seldom the 5 year 100 ccu was well used
i was just scared that id have to jump from a 95 a year to a 95 a month after a year, was like my game better be a success lol
but this is perfectly fine if i can renew
You only need grating the game@indeed gets more ccu
You probably know after a year? ๐
ahhh we never know ๐
Sorry for the typos, I suck at this new phone keyboard
since i have no real clients etc and im not know forging a community will probably take time to reach that 100 ccu
thats alot of accounts
100ccu in practice you need around 2k DAU, around 40k MAU
Thatโs what I see with games with real players
yeah thats what i was approximatly seeing too
Guys i need a bit of help. So i'm trying to make a multiplayer system for my game and i'm using photon. Whenever the player is in the lobby each player is prompted to pick a role (red or blue) and once both of them picked opposite rolls they can start the game.
The thing is whenever they start the game and load into the new scene i wanted it to instantiate the players in two separate parts of the map and currently i'm having a bunch of glitches making it work.
I tried making it work by doing a for cycle that repeats twice (for both players) and that will check the player role and then with that information it will instantiate it in a different spawnpoint.
for (int i = 0; i<=1; i++)
{
Debug.Log(RoomManager.RM.PlayerRoles[i]);
if (RoomManager.RM.PlayerRoles[i])
{
PhotonNetwork.Instantiate(playerPref.name, spawnPoints[0].transform.position, Quaternion.identity, 0);
}
else
{
PhotonNetwork.Instantiate(playerPref.name, spawnPoints[1].transform.position, Quaternion.identity, 0);
}
}
The problem here is that not only does it instantiate 3 objects for the host and only the host (the cycle only runs once, but the first instantiate automatically instantiates 2 prefabs on the host side if I'm not wrong) but the camera glitches out and both players see the vision of the last instantiated player and only the first instantiated player is able to move its character.
My theory is that i have here 2 different glitches, one where it instantiates an extra prefab/photon view for the host and i'm not sure how and the 2nd its an issue with photon views instantiation and considering i haven't properly understood how you are meant to instantiate and transfer ownership of photon views the problem might lie there.
If anyone can help me i'd be extremely grateful, even if it is just to try and help pointing me in the right direction.
your loop only seem to run once, if i = 0, i <= 1 mean 0 only
You have to instantiate each player on their own client after joining a room
the loop was wrong bc i was testing earlier to see if the multiple versions of the player were at fault on the loop or not, my bad for posting the wrong code tho.
But the instantiation on their own client, how do i do that?
PhotonNetwork.Instantiate by default will make the player calling it the owner of it.
It should instantiate on all clients
if i execute it once in the start function does it repeat itself for all players?
Are you trying to instantiate them all on the Master?
Just have each player instantate its own when they join.
And if you need some custom settings, you can instead have them not instantiate until they get a message from the Master telling them to, and what extra info they need.
That invites annoying race conditions though
also what is the best way to get the current player in the room? Let's say i join a room, how can i get my player from the player list of that room? Is there a specific block of code to do that like "PhotonNetwork.CurrentRoom.Players.Mine"? So far i've been doing some work arrounds bc i couldnt find the proper way to do it
So cleanest is just have them instantiate, and then have them set anything custom based on room properties, or an message from the master.
Let's say i join a room, how can i get my player from the player list of that room?
I am not following
Just get LocalPlayer if you want your local player object
PhotonNetwork.LocalPlayer
@jade glacier short version is they pick a room, they pick where they spawn, the master client starts the game and they are meant to be spawned where they picked
They need to wait for permission from the Master or something?
Just have them do that in OnJoinedRoom
i don't want the player itself let's say. I guess i want my number on the Players List.
The Player has an ID, but that may not be what you are after
LocalPlayer.ActorId is your unique connection ID
which increments by 1 as people join
That can get fragmented if people leave and others join
Master is 1, next to join is 2, next to join is 3... if 2 leaves.. next to join is still 4
that might be it?
does that id match the position in csharp PhotonNetwork.CurrentRoom.Players[ /*the id here*/ ]
that is a List no? I don't recall.
Dictionary i think
can actor id reach a max or it loop back from an empty id from beginning
oh shit you are right... i'm an idiot...
if i have people constantly joining and leaving a room
viewID is an int right?
i think so
int.maxValue > any game has ever run in Unity ๐
if viewid are set at the thousand thought for player thats 2.2m numbers
but like im building a mmorpg which scene can be active for a very long time unless there absolutly no one in it for 5 minute
a scene can be a village where people come in and out anytime
the player count would be more like int.maxvalue / 1000 yeah
but still more than I am aware of anyone ever hitting. I would expect it to loop.
But I haven't looked, because why ๐
im really talking to the extreme but if scene is on for a month and people join alot and leave alot in a day that number can get high quick lol
Pun2 is not meant for that kind of game, nothing about it is geared toward persistent anything.
why not o_O
From the ground up it is designed for small player count rooms with a finite existence.
can the room eventually crash
I would hope not, but eventually Unity would just crash.
Time.timeDelta alone will start to break things after too much time.
so far its working well
been online in some room for days
but yeah dint try with a big amount of people
just me myself and i
The code is all right there, you can look at the method for getting a viewID and see if it loops around
I'm working on a multiplayer brawl game and i want to get latency as low as possible. I'm considering the option of p2p to cut latency in half. My package size including header is less than 100 bytes and i'm sending at 30pps. Could it cause issues to have 100+ players inter-connected in a p2p network? Can a router handle it?
I'm using LiteNetLib
@grim violet, PUN will not work with hundreds of players and endless games. It is not built to scale in this way. Small groups. Short-ish running rooms.
It is lacking some features to enable more users and networked objects. You can push the boundaries for sure but .. we won't really put work into support for it.
Long running rooms work against the way we do loadbalancing across machines. So .. you should run your own servers for something long running (which gives options to save state, etc).
im using webhook to save the persisting data
Depends on the player count. All players need updates, so this is where the packages will multiply quickly.
extreme case in a room would be max 50 people, beside the movement of character and animation trigger there nothing im checking on character in general
its a turn based i just want peoplke to walk around and see each other
so far its working super fine
there will be plenty of room too, people will move around
sometime rooms will close by themself cause of lack of people
as i said, 100 players at 30 pps is 3000 packages per second total. Will that be a problem?
3000 packages at 100 bytes each, is 300kb of data being sent each second
doesnt sound like a big deal to me, but i could be missing something
Didn't know that. Turnbased can be very efficient, if you don't send too many "live" updates then. That may work, yes.
yeah im reducing everything to the bottom lol
or i try to
i got map with ressources people can collect, i use custom room properties to hold values while there is people but they get it from my server
they get just once thought, again to minimize data receveid and sent
100 players each send 30pps? then the server probably also sends 30pps to 100 players back?
in a p2p network there is no server
in this case, the client would receive 30pps back from 100 separate connections
Oh, you don't mean "listen server" but real p2p. Then, no, I can not imagine this working properly.
100 people connected p2p? Dude that's crazy
The bandwidth might be doable but those packets won't arrive with nice pacing.
Any stream of packets sent over the Internet can be rearranged, staggered in weird ways, or have duplicates inserted by some router along the way.
If packets from 2 players (let alone 99) for a single frame arrive a bit skewed, you'd potentially have to rollback that frame multiple times. Is your game loop fast enough to do that?
P2P is a term that is misused in networking, so best to always be specific about what you mean.
True p2p is every client directly connecting to every other client. Which is practically unheard of in game networking.
It's not unheard of. How do you think fighting games have netplay? But you are right in that, if you have one client hosting, it'd probably be doable.
Practically unheard of
close enough, I guess
Two player games don't count, since there is no distinction until you have 3+
Two players with one hosting will either be client listen or a lockstep
Yeah. Would you see a true P2P in a "LAN mode"?
Add a third to those and that is where things get messy.
Even lan modes typically have an authority
Unless it's doing a lockstep or something
p2p would have to be lockstep, wouldn't it?
Not sure what all the architecture options are. I have never made a true p2p.
Probably never will. Too messy.
tbh it seems limited in usefulness: 1v1 games built on GGPO or something like it
even in 1997 there were predict/rollback determinsitic games with a central host coordinating input
So pure P2P is just a bad approach IMHO
People always want to try it
Ye, people always want to build MMOs as well
Thinking they will get some miracle result
Erick knows way more than me about this topic btw
I guess the limit with designating a client as the authority is that you couldn't guarantee that client has the network bandwidth (or cycles) to support 100 players.
Especially since the client also has to render its own view.
There is a long list of problems it creates.
#1 is probably cheating
So in client-server and client-host games, how do you ensure clients are predicting ahead just the right amount so their input is highly likely to reach the authority on time but not too early?
Do you just measure ping/jitter and try to maintain whatever lead keeps you at a certain % packet loss?
Prediction just means that objects owner by players simulate immediately. They exist on the future, but are not confirmed yet.
that wasn't the question
You mean how do you manage the server buffer sizes?
No, like, clients will need to predict ahead by a variable amount based on their RTT to the authority.
I guess it's like the reverse of server buffer size?
They don't do that though, they just simulate immediately
No, you will. A client has to simulate frame N at least half their RTT ahead of the server doing it.
We must be talking about different things
I think so
Player prediction refers to letting the client simulate their own objects immediately.
is it possible to setup a server/database for my game on my computer? If so is there a free/cheap way of doing it?
Are you talking more about lag compensating or extrapolating? @dense hedge
@dense hedge is correc
correct
No matter if deterministic or not, you'll be ahead of server with your prediction
I mean, ahead of confirmed data
In quantum, it's normally around RTT/2
in state transfer, it's normally full RTT
Sorry, but I'm a bit busy to explain why atm
His question seems more like how the right buffer size is maintained by the server. If that is the question, that varies. For Fusion clients get constant buffer size feedback from the server, and slightly adjust their sim rate as needed to keep the buffer within spec.
But clients aren't guessing ahead by x milliseconds... They are just simulating on a fixed tick, and sending their inputs for that tick to the server.
If we are talking about predicting your own player objects locally... vs predicting unowned objects.
And my answer is related to state transfer with server authority. Answer likely is different for any kind of lockstep.
I do think my question basically has the same answer as "How do you size the buffer? A constant buffer wouldn't be optimal for someone whose ping goes from 200ms to 50ms or vice-versa.
However, because the server can only buffer a particular input packet until it's time to use it, the client is responsible for adjusting when those packets arrive by adjusting how far in advance it simulates/predicts and sends input.
So conceptually, "time spent in the buffer" becomes "how much to predict ahead," but the value should be the same.
If you had a bird's eye view of all clients at the same time, they should all be simulating a different tick locally.
There are a couple buffers in play of course as well.
If you are trying to server the buffer of inputs on the server... you size that by asking clients to speed up or slow down.
Is that speeding up / slowing down done by dialating the local timestep? I.e. instead of 16ms, the client pretends it's 15ms.
If you are talking about the state buffers coming from the server going to clients, they can have any number of mechanisms for correcting - but typically involve changing their tick offset in relation to the server ticks.
yup
That is the Overwatch method and we use that for Fusion
Right, so I'm more just wondering about particulars of the feedback system that tries to keep the "buffer" as small as it needs to be.
That is subjective. I wrote that segment for Fusion, so I have my way of doing it.
I see. I was reading a bunch of papers about playout delay for VoIP and they do have a variety of methods.
what is fusion
New Photon networking library that is in Alpha
The future replacement for Bolt and Pun
@jade glacier thanks for all the clarification
If anybody could help me out with this I would really appreciate it (working on a online FPS that started out as Local only):
Right now, I am using for each player 2 layers to render the world: the first layer for all the FPS components of a certain player (ex Player1_FPS) and the second layer for all the 3rd person components (ex Player1_3PS) and I do that for the other 3 players: Player2_FPS and Player2_3PF, Player3_FPS, etc This is so the player can see the other player's third person character but not the first person arms. I tired only having 1 Layer for FPS components and 1 layer for third person components but oviously you are then able to see your character's 3rd person body and the other player's 1st person arms.
You do the math and that makes 8 dedicated layers total for 4 players. As I am thinking about making an online mode I came to realise I will run out of layers really fast concidering Unity only allows 32 layers (16 players max) with a few already dedicated for the engine.
I think I am completly missing something, but I am struggling finding information on this.
Any help would be awesome.
Cant you work with the islocalPlayer (not the actual name) bool instead of layers ? And disable rendering or not spawn at all based on that ?
Hi thank you for your answer, a few people already answered this in another channel. Still, thank you!
Great, happy coding !
Hello all, i dont quite know where to put this but i just set up a project using OVR (VR) and Photon 2, I set the basics up it worked for a sec and then i start having problems with the editor crashing on play. If anyone knows how to read editor logs may you check to see if it is photon related ?
I don't see any pointers to problems with PUN. It's also not known to crash Unity, so it's more likely something else.
hey people I have a really dumb question I'm just not experienced with web stuff. If I'm using UnityWebRequest do to a POST to a https link am I automatically secured with SSL? I mean the POST does not go in plain text form right? I'm also using a WWWForm for the data itself.
Which technology is best for making a game like club penguin mmo? I heard they used smartfoxservers but photon seems more intertwined with unity and the more popular choice. Also I've heard photon isn't good for mmo's
hey all, i'm using PUN 2 in my project, and following some tutorials to try to import photon 2 Voice as well. none of the tutorials thus far have described what to do when you import photon 2 Voice and the package looks to want to overwrite 90% of your existing PUN 2 library. anyone know if you're supposed to go ahead and overwrite?
also @silent flame curious if you heard any specific reasons about photon not being good for MMOs -- and which alternatives might be better
@fading chasm not a specific reason. I heard that they are good for games <32 people and they are working on being better for larger people games. This was all in those "don't make an mmo" posts so maybe the answers were just trying to be discouraging to the posters.
I am not experienced with multiplayer dev yet so I was trying to find the right technology for my game. Sadly most posts suggestions are "dont build mmo" but I am not trying to do anything commercial anyways just wanting to learn ๐
Look at the network plugins based on popularity on the asset store then look at the reviews and read the reviews to get some sort of idea https://assetstore.unity.com/tools/network it's important you read the reviews. Use the Sort By to work it out. Also if they've support whether it's Unity Forums or there own forums, go and read them. Tons of support out there.
will take a look rightaway. thank you
thanks for the help!
You can also check out this blog: https://blogs.unity3d.com/2020/09/08/choosing-the-right-netcode-for-your-game/
Or this forum thread:https://forum.unity.com/threads/what-are-the-pros-and-cons-of-available-network-solutions-assets.609088/
to learn more about available networking solutions for Unity.
Awesome. Looking at these now also. Thanks a ton!
Not a lot of people will share there results on what they use, some people just keep it to themselves and will rarely share the answers because it's just to much of a massive playing field to give the right answer, sure PUN might be useful to the person running 48 players or 12 players but remember if someone says something isn't good for MMO that is because that is based on there experience, not yours, don't let it get you down. There answer is there, you just need to explore all avenues.
That makes sense ๐ thanks!
I would love to say use BLAH but I don't know anything about your project, the ins and outs of it and everything in between, what I can do like a lot of others like @verbal lodge is provide links to resources which will help you learn a little more and push you in the right direction so one day someone else will be on here asking the same question and you'll be here and you'll be able to answer because you know exactly how you felt when you asked.
Photon Voice includes PUN 2 but in a specific revision (which fits perfectly with that version of Photon Voice). Yes, let Voice overwrite the PUN 2 files on import. From then on, don't import PUN 2 on it's own anymore.
As long as you are new to multiplayer, you should do yourself a favor and set smaller goals. You will learn that it's not possible to answer questions like "i am new to multiplayer and want to make an mmo. how can i do this?".
You don't have to give up your MMO ambitions. Just take some time to learn the basics. Do a game for 2, then 4 and more and more players.
It helps you realize the problems you run into when you sync games and when you add more and more players. This is nothing the "right" engine will solve, when you talk about MMOs. Pretty much all networking solutions only solve problems for < 32 players. Maybe 50 or so. Anything above that will require some more knowledge, which can not be explained in a few lines of chat.
Thanks @stiff ridge!
Thanks so much @stiff ridge and @white stone both were really insightful. I will try to dive into mirror and see what i can learn out of that
How non deterministic is physx? Should I be expecting wildly different positions on different devices?
or should they be somewhat the same?
They will drift
And over time butterfly effect plays itโs role and things get totally different
Itโs not wildly different on the first seconds
This is a picture of another person
this is not showing up for me for mirror
but for other things like Unity.engine and system it is working
So the newer releases of unity have "enhanced determinism" as a setting
how bad is the performance scaling with this?
Can someone explain how I would to the lerping on the clientside after the clientside reconciliation is finished?
like I've got the old position, and the new re-simulated position
I just can't figure out how to do this smoothly
My other option is to just not lerp at all, but then the player jumps and it's somewhat noticeable
@slow monolith you keep the last two position-time pairs sent from server
and use them to interpolate depending on the current time
https://gafferongames.com/post/snapshot_interpolation/
This should talk about that in more detail
Introduction Hi, Iโm Glenn Fiedler and welcome to Networked Physics.
In the previous article we networked a physics simulation using deterministic lockstep. Now, in this article weโre going to network the same simulation with a completely different technique: snapshot interpolation.
Background While deterministic lockstep is very efficient in te...
@high night Having an awful time trying to wrap my head around this. The positions are interpolated over several frames, but what happens if the client moves during that interpolation?
do you currently have predictions going on currently with this scenario?
then this is not about that article or what i said
you are asking how to do the rubberbanding smooth?
the times when client predicts the character wrongly i mean
@slow monolith
lets say you have your characters physics and logic seperated from the visuals
for physics body, you should instantly replace it to its new correct position
and the visual one should always follow the physics one via something like snapshot interpolation
So technically my camera shouldn't be on the rigidbody? It should be on something following the rigidbody?
and make the real rigidbody invisible?
if the camera is going to be smooth, it cant directly be on the rigidbody, or directly following the rigidbody
Yes, i'd make the real logical character invisible
And when you shoot a bullet, you shoot it from rb, not the camera
alright
wym by the camera can't be directly following the rigidbody?
was that a typo?
What I meant is, have another gameobject lerp to the rigidbody
whenever it moves
I am talking about making another gameobject following the rigidbody
and thats the visual model of the character
and camera
lerp wont be super smooth
you'd have to do that little more complicated lerp i was talking about
yeah I would have no clue how to even start on that
if you tried to lerp like you are thinking right now, you'd notice some issues with it as speed gets a little higher
yeah
isn't smoothdamp a fix for that though?
pretty sure you can cap smoothdamp speed too
the thing is
you need to lerp like this:
interval = (time - prevTime) / (nextTime - prevTime)
lerp(somePrevValue, nextValue, interval)
instead of:
lerp(currentValue, nextValue, constantNumber)
@slow monolith
To keep the lerp consistant
yeah I think the docs have something similar
if I'm not mistaken
just never played with it before
Mathf.Lerp or Vector3.Lerp already has what it needs
You just dont wanna plug the current value in there
Perfect, thanks for the help
You understand what i mean by all that?
Okay then
Good luck
@slow monolith Why do you have these prediction errors anyways?
You shouldn't have much of them predicting the local player?
Both server and client uses rigidbody to move the player
so naturally as erick stated, they'll start to drift apart
If I used character controller to move them, there would probably be a lot less
until packet loss hits
if these drifts are too noticable, maybe there are some things you can do to improve the determinism
Or maybe you aren't syncing velocity or something when you adjust the rigidbody into its previous state
nah I'm syncing everything fine, it's just during my tests I purposely reconciliate on every packet received
just so test it
your previous solution should work just fine
allright
I also tested only teleporting the player to the new re-simulated position with no lerp, and the teleport was extremely tiny
but noticeable
cant move on until its perfect
@high night Last thing. So when I build my cars and have a first person cockpit view, I would have an invisible car-sized rigidbody, then the actual car model would be lerping to that rigidbody's position?
yes
Thanks
player and car and camera following the rb the same way
How would I do the wheel colliders? Just make the wheel rotation follow the invisible rigidbody's wheel colliders?
Also the visual model shouldn't have any colliders on it, right?
i'd make a nice system to sync objects with that lerpy buffery technique
it would do that lerp for position and rotation
I'd make the car body model follow the rigidbody car body
and wheel models should follow the real invisible wheels the same way
@slow monolith no colliders/rbs on visual models
Alright thanks
Also how do I make sure the rigidbody and the visual gameobject don't get too far apart?
is that in the lerp function you gave me?
@high night
Also how many games have you used this method in?
I dont have a good solution with dealing with that falling apart problem
@slow monolith I never really got to use this anywhere yet, always had simple lerps as placeholders that i didnt get to upgrade
You could try extrapolation but you'd lose the perfect sync
Like if the car is taking a turn and you extrapolate the visuals, the turn radius will be higher than the rigidbodys turn radius
Maybe extrapolation wont be too big of a deal
You'd just have to add some extra time on the lerp interval
So that it always matches the client time
That time would be proportional to client latency