Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

What exactly is bending? #141

Open
paridigm opened this issue Jul 21, 2021 · 3 comments
Open

What exactly is bending? #141

paridigm opened this issue Jul 21, 2021 · 3 comments

Comments

@paridigm
Copy link

I feel that I've read everything on lance-gg.github.io that I can about bending, ie localObjBending and remoteObjBending, and I don't think I quite understand it. So, I'm hoping to get some clarification on it.

I'm a pretty decent front-end developer (I created my own front-end framework, https://duckjs.org, not trying to self-advertise, just trying to show where I'm coming from and my level of understanding), but I hardly know anything about "netcode" as they call it. From what I've researched, it's generally good to have an "authoritative server". And, according to https://forum.unity.com/threads/authoritative-server-definition.209320, I think an authoritative server system means that the server owns all data and has the "final say" in all actions, meanwhile, clients focus on rendering the server state in the best possible way and transmitting user input data to the server.

My questions regarding bending:

  1. Does remoteObjBending mean that clients have some authority over server state? Ie, is the server adjusting itself slightly to the state of clients?

  2. Does localObjBending mean that the client is bending its local state back to a previous version of its own state? If so, what is the purpose of that?

  3. Does bending only happen when using syncMode=extrapolate?

  4. Does syncMode=interpolate perform bending?

  5. Is extrapolation better than interpolation? In what contexts would you use one vs the other? It seems like you have to choose one or the other in Lance, ie you can't use both. So, I'd just like to inform myself.

  6. Also, I know this is obviously unrelated to Lance, but I found another framework called Colyseus that seems to have become popular. Is there a reason why people might choose Colyseus over Lance other than the fact that Colyseus looks like it's more client-ignostic (ie works with Unity, Cocos, Construct, etc)? I'm personally trying to make a simple browser-based multiplayer physics game similar to https://github.com/lance-gg/sprocketleague, so the built-in integrations with Cannon/P2 in Lance just make so much sense to me. I went through the Lance pong example, and I'm very impressed with how everything in Lance is architected. So, I'm really just asking this because Lance seems ideal to me, and I see no reason to use Colyseus assuming that Colyseus would perform the same stuff (ie "netcode") as Lance and with the same level of performance, right? Also, I didn't find anything on Colyseus about bending.

PS
Sorry this is a lot of questions, but I'm hoping to get some answers so that I can start building my game in Lance!

PPS
I also wanted to say thanks to all the developers for this awesome project!

@OpherV
Copy link
Member

OpherV commented Jul 22, 2021

Hi @tomknappramos !
Lance founding and core member here. Happy to answer you questions :)

I gave a talk about this once in a conference, their audio is not great but it does cover a lot of the points here:
https://www.youtube.com/watch?v=V2cvGD7Yeak

I'll try to address your questions.

1 & 2 -
"local" objects are those with properties that are under the player's control, while "remote" are those that aren't. It tackles the problem of "who has the newest information". Think of a spaceship game - when you pilot YOUR ship on your own computer, you are the one who has the newest information about its intentions and movement. The server will get those movement requests eventually a, but as the ship controller you expect it to move and react smoothly to your input. IE when you press a key, you expect to see the ship moving immediately. Contrast this with another player's spaceship - you don't control it, so you wouldn't have a way to notice if there's a slight discrepancy between the time they pressed a key to move it and when it actually moved on your screen.

The client is ALWAYS adjusting itself to the server's authority. That's what authoritative server means. A lot of this stuff is visual trickery to make it appear as if everything is running in "realtime".

3 & 4. Interpolate indeed performs bending. Take a look at the interpolate strategy

  1. These are different solutions to different problems. See
    https://lance-gg.github.io/docs_out/tutorial-guide_syncinterpolation.html
    and
    https://lance-gg.github.io/docs_out/tutorial-guide_syncextrapolation.html

I also cover which should be used when in the video linked above around the 19:00 mark

  1. Honestly I'm not really familiar with Colyseus. Lance was built from the ground up to serve the needs of 100% native JS web-based games. Having said that, Lance is being maintained but no longer actively developed. I have plans for further development in the future, but I don't know how far along in the future.

@paridigm
Copy link
Author

paridigm commented Jul 23, 2021

@OpherV thanks for getting back! I appreciate it!

I got the vibe that Lance was "no longer actively being developed", but it works and the development experience is great. So, for me, it's worth a try! Plus, look at C. It's the leading language used in the game dev industry, and I don't think anyone is actively maintaining very many C libraries these days (I could be wrong on that haha).

1&2,
I'm glad that I confirmed that the bending mechanisms don't affect the server (ie, the server does in fact have "full authority")! I mainly wanted to confirm that! And, just get a more solid grasp on what's going on, would you say this right?

Clients store 2 types of states,

  • remote state - state that came from the server
  • local state - state that comes from running the game locally

To appear "live", clients go ahead and simulate user actions on the local game engine right away. But! Clients don't do the actions completely. Instead of fully commiting to the simulated next state and rendering that next state, the client can approach the simulated new state, and bending is the percent at which clients approach that next state. That is localObjBending.

Then, when a remote state comes in from the server, to avoid choppiness, clients can gradually approach that "actual remote state". Where, again, bending is the percent at which clients approach that most recently known "actual remote state". That is remoteObjBending.

So, clients are bending towards 2 things - bending towards the "simulated next state" as well as bending towards the "most recently known remote state".

Personally, my instinct tells me to set both to 1. That just seems logical to me.

3&4,
Noted! I would have assumed that interpolation mode would have no localObjBending seeing that it's simply connecting the dots between remote states?? Sorry, I'm still learning... Also, the timing graphs on the Lance website go over my head... For some reason my brain doesn't comprehend them well at all. I understand the ideas of interpolation/extrapolation, but those graphs probably would have to be like a video or something for me to understand them haha.

5,
For real-time games (the best kind of games... IMO haha), like Sprocket/Rocket League or first-person shooters, it seems like extrapolation is 100% the way to go because you want things to feel as snappy as possible. Extrapolation is obviously more challenging because clients have to actually run the entire game engine - not just run a rendering engine.

6,
I could see that the primary appealing aspect of Colyseus is that it's cross-platform, ie it looks like it has a lot of client libraries for different platforms. That's probably nice, but, I gotta say, it's hard to beat isomorphic js running Cannon/P2 on server & client haha it's just so buttery.

PS
The video audio is rough indeed. Good talk though!

PPS
Any of you guys play Rocket League btw? I'm diamond 1 in 3s & gold 3 in 1s haha

@paridigm
Copy link
Author

Also, is bendingIncrements a multiplier on the bending properties?

Ie, would
localObjBending=0.2, bendingIncrements = 1
be the same as
localObjBending=1, bendingIncrements = 5

Thanks again!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants