Jump to content

Leadwerks Multiplayer Controller Theory


gamecreator
 Share

Recommended Posts

I was thinking about how a multiplayer game with Leadwerks would work and I'm curious about if anyone else successfully pulled it off, or has thoughts on it.

My understanding is that the host and the clients both simulate locally.  Then, every few frames, the host makes sure everyone is where they should be.  If they aren't, he tells the clients to correct in the past, where they started diverging, and simulate from that point again (having kept position/rotation and input history).  That means that every once in a while, the clients need to simulate multiple frames' worth of stuff in a single frame.

I may have to test it but is this something Leadwerks is fast enough to do for a scene with multiple players and enemies?  (I understand that there are a lot of variables here like triangle and bone count.)  Also, can the character controller be properly set to a position/rotation/velocity/acceleration?

What's the best way to do this?

Link to comment
Share on other sites

1 hour ago, gamecreator said:

If they aren't, he tells the clients to correct in the past, where they started diverging, and simulate from that point again (having kept position/rotation and input history).  That means that every once in a while, the clients need to simulate multiple frames' worth of stuff in a single frame.

Why would the server do that? It should instead just tell the client the correct current state, the client takes this state as the new truth (it might use some smoothing operations, so the objects don't flip around) and starts simulating from that new state again... No need to simulate the past, if the actual current state is known. This network-model you are describing is called "client side prediction" and by googling that term, you should be able to find lots of articles to help you further with this.

Link to comment
Share on other sites

I suspect it's to save on packet size.  Say a grenade was supposed to explode a few frames back among a group of characters.  It's less information to send that grenade information in the past to all clients than to send every character's.

Also, there is always latency.  By the time you get a confirmation from the server, you will be several frames past from when the server said you were where you were.  So it makes natural sense to send a time stamp and simulate from the past.

Link to comment
Share on other sites

Yeah, it usually takes a few reads to figure out. :)

 

The thing with LE is that you can't really do a client/server architecture since you need the gfx in LE to be initialized and servers generally don't have that. LE really needs the physics simulation to be separate from the renderer for client/server to really work. So it's basically peer to peer for networking in LE otherwise it's a lot of work as you'd need to run Newton library separately on the server.

Link to comment
Share on other sites

I've been looking at Minion Masters (free on steam) and think that's a good game for LE. Honestly no physics even required for that. Just A star pathfinding and the player just places units ont he board and the units do their own thing. I'm looking at possibly trying to make something similar.

Link to comment
Share on other sites

13 hours ago, gamecreator said:

True, it's ideal to make a server a separate non-player.  For me the host is also the player so I'd need to get clever.  Still tempting to look at turn-based games for simplicity but I'm really an action game type of guy.

One of the nice things about the Steam P2P networking is the game is not dependent on a central server always being maintained.

My job is to make tools you love, with the features you want, and performance you can't live without.

Link to comment
Share on other sites

Just do it, in the simple dumb way at first.And solve the problems along the way.

For fps you will probably need a binary network protocol.But for initial testing just have server/client use strings (csv or json if you want).

 

Probably using Le steam network could be simpler.

 

Some libs you could use c/c++:

Asio, SDL_net, POCO Net, libevent.

Also i used go lang a couple of times for the server, simpler.

 

  • Like 1
  • Upvote 2

I made this with Leadwerks/UAK:

Structura Stacky Desktop Edition

Website:

Binary Station

Link to comment
Share on other sites

1 hour ago, Mr_SquarePeg said:

So I posted this in the Lead Werks discord and I might as well post it here.
https://coherence.io/

Thanks but their launch is in 2020.  There are other alternatives like Amazon's GameLift and PlayerIO.  But mostly I was concerned about how Leadwerks would handle the extra load with character controllers, or if there's a better way to do it, and this for a player host.

Link to comment
Share on other sites

I have no idea why people are still searching for a basic networking system when we have a good one that works right now.

The P2P class lets you send messages to any Steam ID.

The lobby system functions as a game server. The owner of the lobby can act as the central server:
https://www.leadwerks.com/learn?page=API-Reference_Object_Lobby_GetOwner

If the owner leaves, a new owner will be automatically chosen, based on whichever player has the most optimal location to reach the other players. You can also set up one computer with a Steam ID to act as a central server, if you wanted to.

It's a fantastic system that makes it easy to get started.

  • Like 1
  • Upvote 1

My job is to make tools you love, with the features you want, and performance you can't live without.

Link to comment
Share on other sites

That's awesome and I love the features and I agree that this is the ideal solution for a lot of situations.  But all I'm saying is that once you start testing games with multiple players and a bunch of enemies (as I have), merely sending packets back and forth is not enough.  You need to account for lag spikes, different frame rates, etc. and need to optimize packets for the smoothest experience.  I was surprised at how quickly I needed to do this despite having a decent internet connection.

Link to comment
Share on other sites

You can store a value with unreliable packets that increments with each new packet sent. The receiving computer can then discard packets that are less than the max value received, so that only the latest data is used.

For movement you can either interpolate between the last two positions received, or extrapolate using the current velocity.

There's not much else you can do. It's not like you can create information where none exists. Limiting the number of packets is important.

  • Upvote 1

My job is to make tools you love, with the features you want, and performance you can't live without.

Link to comment
Share on other sites

6 hours ago, Josh said:

There's not much else you can do. It's not like you can create information where none exists.

i watched this great GDC talk about how they did networking with Halo.  They got really clever with a lot of their packets (customized a lot of them given the situation).  For example, see what they tried with Armor Lock at 35:41 and why it failed and how they fixed it.

 

  • Like 1
Link to comment
Share on other sites

Couldn't you just tell the client "a grenade is exploding" and let it decide whether that incurs damage or not, and send that result to the host?

  • Upvote 1

My job is to make tools you love, with the features you want, and performance you can't live without.

Link to comment
Share on other sites

Of course but if the client decides important things like this then the game is susceptible to cheating/hacking.  That's the idea behind making the host authoritative.

Now, the other thought is that if your host is also a player, what prevents them from cheating?  This is when you can get hardcore and rent or buy your own server but I'm not there yet.

Link to comment
Share on other sites

6 hours ago, Josh said:

Couldn't you just tell the client "a grenade is exploding" and let it decide whether that incurs damage or not, and send that result to the host?

In most all multiplayer games you can't let the clients decide anything as important as to incur damage or not or how much. That game would run rampant with cheating. This is why peer to peer networking with no server works in only certain types of games. Most games don't work well with that model.

Link to comment
Share on other sites

1 hour ago, Lethal Raptor Games said:

How does one cheat in a game?  If you protect your files and don't provide a console and don't make cheat codes... how can it be done?

You can not 100% protect the game files. You can only make it hard enough for an attacker to eventually give up and lose interest in deobfuscating what you did. The reason, why it is not possible to protect the files is that the pc must be able to execute and therefore decrypt your files and an attacker can simply e.g. attach a debugger to your program and read the contents from memory or reverse engineer the decryption-process. For this reason, one option for an attacker to cheat is by simply modifying the game files.

For multiplayer games, an attacker can actually simply send data to the players / the server, without even touching your game files, if they figure out the protocol you are using. They can learn about your protocol e.g. by simply analyzing networking-dumps. The other party does not have any possibility to check that the data was sent from your program and not from any other program capable of sending networking-packets.

Link to comment
Share on other sites

On the file editing side, if your game is with Steam and someone does manage to edit a file and change the way the game plays, I would think Steam will see that the bits no longer match and your game is in need of an update? Which will reset everything.

The multiplier side of is vulnerable.

Link to comment
Share on other sites

2 hours ago, Lethal Raptor Games said:

How does one cheat in a game?  If you protect your files and don't provide a console and don't make cheat codes... how can it be done?

Given this is a post about multiplayer the cheating would be on the network commands they can send or suppress if they are the host of the game (for games that have no central server). 

  • Like 1
Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

 Share

×
×
  • Create New...