Register a SA Forums Account here!
JOINING THE SA FORUMS WILL REMOVE THIS BIG AD, THE ANNOYING UNDERLINED ADS, AND STUPID INTERSTITIAL ADS!!!

You can: log in, read the tech support FAQ, or request your lost password. This dumb message (and those ads) will appear on every screen until you register! Get rid of this crap by registering your own SA Forums Account and joining roughly 150,000 Goons, for the one-time price of $9.95! We charge money because it costs us money per month for bills, and since we don't believe in showing ads to our users, we try to make the money back through forum registrations.
 
  • Post
  • Reply
Spek
Jun 15, 2012

Bagel!
Hmm I think maybe something like that. It had never occurred to me to store an index on the vert.

I had been focusing on thinking of ways of sorting the finalized array, but I could leave the original verts completely unsorted which stores them in the vertex array in a way where the position of all verts is semi-predictable based on their position(I'm not doing this now because it means there's 10s, if not 100s of thousands of unused verts stored that way). I think I would then only need to check 6 surrounding cubes * 5 tris per cube * 3 verts for duplicates, then store the index on the vert so I can use that instead of re-searching the list every time.

That seems like it might work, will give it a shot anyway.

Adbot
ADBOT LOVES YOU

big scary monsters
Sep 2, 2011

-~Skullwave~-
I have a Godot problem. I have a RigidBody that I am rotating with add_torque() and moving with add_central_force(). I want to compare its rotation with the global down direction - imagine trying to find the pitch angle of a plane (the flying type) for instance. Here is a basic script applied to a cube (just a RigidBody with MeshInstance and CollisionShape), with user controlled rotation and a call to an ImmediateGeometry node to visualize the axes.

code:
extends RigidBody

onready var immediate_geometry : ImmediateGeometry = $ImmediateGeometry

var forward : Vector3
var right : Vector3
var up : Vector3

var global_down : Vector3

var rot_forces : Vector3
var input_pitch : float
var input_roll : float

func _ready():
	forward = transform.basis.x
	up = transform.basis.y
	right = transform.basis.z
	
func _physics_process(delta):
	global_down = global_transform.basis.xform_inv(Vector3.DOWN)
	
	rot_forces = Vector3(input_pitch, 0.0, input_roll)
	
func _integrate_forces(state):
	add_torque(rot_forces)

func _process(delta):
	immediate_geometry.draw_axes(self)
	input_pitch = Input.get_action_strength("move_forward") - Input.get_action_strength("move_backwards")
	input_roll = Input.get_action_strength("move_right") - Input.get_action_strength("move_left")
Where
code:
global_down = global_transform.basis.xform_inv(Vector3.DOWN)
is the relevant line to figure out the down direction.

However, this vector wanders as the object rotates, and not just a bit. Within a few rotations it is 10-15 degrees off where it should be. Here is an example with a spinning cube, with the coloured lines showing the local xyz axes and the black line global down, first at rest and then spun up for a few seconds.




As the rotation slows the global down gradually returns to where it should be - here's the same cube once it's come to rest in a new orientation.


The docs mention this problem as being a result of floating point precision errors and say there are two ways to address it, one of which is to use orthonormalized(). I haven't been able to figure out a way to apply that that helps. The second solution they are apparently keeping a secret, although from looking around it seems that something to do with quaternions may help. Since I'm not rotating the RigidBody directly but applying forces I'm not sure where they would enter the picture though. Any ideas how to get a consistent global down direction inside this local space? Or to calculate the angle between global down and a local vector another way?

Jabor
Jul 16, 2010

#1 Loser at SpaceChem
Are you sure it's not just that you're computing which direction is "down", and then the orientation of the cube is being updated before anything is actually drawn on screen?

That would match your observation that the amount of error is proportional to how fast the cube is spinning.

big scary monsters
Sep 2, 2011

-~Skullwave~-
Hmm, I think you are right! If I move the immediate_geometry call to _physics_process just before I calculate global_down then it wanders a lot further - it gets right up above the horizontal. I suppose that's because it's an extra physics frame behind. If I put both global_down and immediate_geometry in _integrate_forces after the apply_torque() call then the down axis stays where it should be.

I guess that means I have to do my physics calculations a frame "ahead", after apply forces in the current frame. Thanks, I would have been banging my head against that one for ages.

e: Actually it works even if global_down and immediate_geometry() are before apply_forces() in _integrate_forces. I think I have to figure out the timing between these functions - I thought _physics_process just called _integrate_forces each time it ran.

big scary monsters fucked around with this message at 11:33 on Apr 17, 2022

xgalaxy
Jan 27, 2004
i write code
I’m not a graphics programmer and I don’t have a lot of experience with Unity specifically.

Is there a reason why a lot of games made in Unity going for this 2.5D look tend to do it by slanting the 2D portions by 30 to 60 degrees and using a vertex shader to skew the 3D elements, well all except the ground plane? Example

More concretely I’m wondering, if one were not using Unity, eg making an engine from scratch, if there would be a more direct approach. Put another way, is there some sort of technical limitation Unity imposes that makes the above approach the common one? Or would this simply be how you should do it in a custom engine too?

Thanks.

leper khan
Dec 28, 2010
Honest to god thinks Half Life 2 is a bad game. But at least he likes Monster Hunter.

xgalaxy posted:

I’m not a graphics programmer and I don’t have a lot of experience with Unity specifically.

Is there a reason why a lot of games made in Unity going for this 2.5D look tend to do it by slanting the 2D portions by 30 to 60 degrees and using a vertex shader to skew the 3D elements, well all except the ground plane? Example

More concretely I’m wondering, if one were not using Unity, eg making an engine from scratch, if there would be a more direct approach. Put another way, is there some sort of technical limitation Unity imposes that makes the above approach the common one? Or would this simply be how you should do it in a custom engine too?

Thanks.

That's not how most people do 2.5d. That is used because whoever is making the game holds an intense and possibly irrational adoration for the Ultima series. It's intensely a Choice, not some default look.

xgalaxy
Jan 27, 2004
i write code

leper khan posted:

That's not how most people do 2.5d. That is used because whoever is making the game holds an intense and possibly irrational adoration for the Ultima series. It's intensely a Choice, not some default look.

Enter the Gungeon is another example.
But yes, I accept that it’s a choice.

12 rats tied together
Sep 7, 2006

if you have a sprite in a 3d world it will clip into geometry at some positions, most notably in the gungeon example, if the walls went straight "up" and the camera was set at the intuitive angle for that shot, the upper half of the sprite would disappear behind the wall when the player was standing underneath it

you can google "2.5 sprite clip" for some discussions about it. I render my sprites as a partially transparent texture on a plane (three.js, not unity), which means they exist "normally" in the world and I don't have to deal with this problem, but as a tradeoff I have to scale their height depending on the camera pitch to compensate for foreshortening

quick example from some reddit thread on this topic:


Chainclaw
Feb 14, 2009

xgalaxy posted:

I’m not a graphics programmer and I don’t have a lot of experience with Unity specifically.

Is there a reason why a lot of games made in Unity going for this 2.5D look tend to do it by slanting the 2D portions by 30 to 60 degrees and using a vertex shader to skew the 3D elements, well all except the ground plane? Example

More concretely I’m wondering, if one were not using Unity, eg making an engine from scratch, if there would be a more direct approach. Put another way, is there some sort of technical limitation Unity imposes that makes the above approach the common one? Or would this simply be how you should do it in a custom engine too?

Thanks.

It's not just done in Unity, and not just done for 2D games. Sometimes you'll render or model geometry in ways to play well with a camera angle.

Link Between Worlds is the example I think of the most for rendering offset for the camera.

more falafel please
Feb 26, 2005

forums poster

It's the same tricks pixel artists used to make sprites in a particular perspective, just in 3D.

giogadi
Oct 27, 2009

Does anyone have experience with Unity’s Native Audio framework? I’m using it to make a synthesizer that I can control at runtime.

My question is about threading - does the native audio thread run in parallel with C# scripts? I’d like to use a script to change the synthesizer’s parameters at runtime, but I have no idea whether it’s safe to be poking the audio system’s memory from a script. Intuitively, it seems like they must be running concurrently since the audio could be ticking at 44100Hz while the scripts are ticking at 60Hz or whatever.

I could always throw mutexes around all the shared memory accesses but that might slow things down too much on the audio side.

KillHour
Oct 28, 2007


Unity does not want you managing threads on your own at all. Any unity package will have thread safe apis they expect you to use.

Edit: according to the documentation, unity expects you to surface hooks to your parameters that they will expose for you. Follow whatever they did in their example code I guess.

https://docs.unity3d.com/Manual/AudioMixerNativeAudioPlugin.html

KillHour fucked around with this message at 15:31 on Apr 25, 2022

giogadi
Oct 27, 2009

Oh I see, so the Exposed Parameters are the intended interface between scripts and audio plugins. If I understand correctly, params can only be floats so it’ll take some thought to figure out how to specify sequences and schedule note-on/off events based on individual floats, but at least I know what the expected way forward is. Thanks!

KillHour
Oct 28, 2007


giogadi posted:

Oh I see, so the Exposed Parameters are the intended interface between scripts and audio plugins. If I understand correctly, params can only be floats so it’ll take some thought to figure out how to specify sequences and schedule note-on/off events based on individual floats, but at least I know what the expected way forward is. Thanks!

I was just doing stuff with MIDI (not with the native audio plugin though) and this might help:

https://github.com/keijiro/Minis

Notes are floats anyways because you need to encode the speed/pressure of the note.

giogadi
Oct 27, 2009

Thanks, I’ll take a look.

I wonder sometimes if I’m taking on too much by building a synthesizer in unity. My overall goal here is to make a music game where the player’s actions influence the music being played, and it seemed much easier to prototype ideas with a runtime synth, rather than prerecording sounds and playing them.

Ideally, unity would just have a synthesizer component that I could control similarly to JavaScript’s WebAudio API. There’s a tool on the asset store called “Helm” that tries to do this, but it has some issues I couldn’t get around because it’s closed source.

I have some exciting prototypes working in JavaScript but I really don’t like working in JS, and I’m always afraid that some browser update will come around that just breaks all my stuff one day.

This is all fine because building my own synth from scratch has been on my bucket list for a while, but it definitely feels a little like “I want to make a game; guess I’ll write my own engine first”. There’s a looooot more to building a synthesizer than I expected, but the math behind it is super interesting.

KillHour
Oct 28, 2007


https://unitylist.com/p/ut9/Unity-DSP-Graph-Modular-Synth

giogadi
Oct 27, 2009

Ooooooh interesting. I wonder if it’s worth trying to jump on the DSP Graph train this early. More to think about!!

KillHour
Oct 28, 2007


Doesn't matter whether you want to jump on that train or not - use what exists and make sure you're not tightly coupled to it. If you plan for it, you can use it to do the prototyping you wanted to do and make it easy to rip out later and replace with whatever you want to actually use. It sounds like you're still in the PoC phase anyways.

sailormoon
Jun 28, 2014

fighting evil by moonlight
winning love by daylight


I've recently made my own rollback netcode in Golang with WebRTC with the ability to compile it down to webasm :toot:

However, I want to start using a fancy schmancy engine since I want to delve into simple 2.5D graphics and my current engine is built on Ebiten which is 2D only.

I have expertise in C++ and the masochism to enjoy writing it, but I was curious if any of the big 3 engines from Unity, Unreal, Godot, or Mystery Engine Number 4 support:
* A headless server where I can control and run the game loop
* The same as the above except for the client, ideally sharing code between the two
* WebRTC and webasm support so the game is easily distributable
* Preferably more on the programming side than the GUI side

It's a pretty big wishlist 😢 I'm hoping I can continue using mostly the same code base for the server and the client.

I'm not looking to do anything too complex graphically so maybe a 3D rendering library is actually what I need...

leper khan
Dec 28, 2010
Honest to god thinks Half Life 2 is a bad game. But at least he likes Monster Hunter.

sailormoon posted:

I've recently made my own rollback netcode in Golang with WebRTC with the ability to compile it down to webasm :toot:

However, I want to start using a fancy schmancy engine since I want to delve into simple 2.5D graphics and my current engine is built on Ebiten which is 2D only.

I have expertise in C++ and the masochism to enjoy writing it, but I was curious if any of the big 3 engines from Unity, Unreal, Godot, or Mystery Engine Number 4 support:
* A headless server where I can control and run the game loop
* The same as the above except for the client, ideally sharing code between the two
* WebRTC and webasm support so the game is easily distributable
* Preferably more on the programming side than the GUI side

It's a pretty big wishlist 😢 I'm hoping I can continue using mostly the same code base for the server and the client.

I'm not looking to do anything too complex graphically so maybe a 3D rendering library is actually what I need...

Unity has a headless server, but IMO it's better to not rely on their physics and handle state synchronization outside the engine context.

BabelFish
Jul 20, 2013

Fallen Rib

sailormoon posted:

I've recently made my own rollback netcode in Golang with WebRTC with the ability to compile it down to webasm :toot:

However, I want to start using a fancy schmancy engine since I want to delve into simple 2.5D graphics and my current engine is built on Ebiten which is 2D only.

I have expertise in C++ and the masochism to enjoy writing it, but I was curious if any of the big 3 engines from Unity, Unreal, Godot, or Mystery Engine Number 4 support:
* A headless server where I can control and run the game loop
* The same as the above except for the client, ideally sharing code between the two
* WebRTC and webasm support so the game is easily distributable
* Preferably more on the programming side than the GUI side

It's a pretty big wishlist 😢 I'm hoping I can continue using mostly the same code base for the server and the client.

I'm not looking to do anything too complex graphically so maybe a 3D rendering library is actually what I need...
Unreal's got systems for handling what you're looking for, though I don't know if their 'pixel streaming' system uses WebRTC and webasm under the hood.
https://docs.unrealengine.com/5.0/en-US/setting-up-dedicated-servers-in-unreal-engine/
https://docs.unrealengine.com/5.0/en-US/pixel-streaming-in-unreal-engine/

more falafel please
Feb 26, 2005

forums poster

BabelFish posted:

Unreal's got systems for handling what you're looking for, though I don't know if their 'pixel streaming' system uses WebRTC and webasm under the hood.
https://docs.unrealengine.com/5.0/en-US/setting-up-dedicated-servers-in-unreal-engine/
https://docs.unrealengine.com/5.0/en-US/pixel-streaming-in-unreal-engine/

If OP is looking to support a lockstep/rollback networking model, UE4 doesn't do that out of box. UE4's networking is great, but it's very focused on a server-authoritative model. We've put rollback into UE4 for games before, but it's a big effort, probably more than a solo developer wants to take on.

BabelFish
Jul 20, 2013

Fallen Rib

more falafel please posted:

If OP is looking to support a lockstep/rollback networking model, UE4 doesn't do that out of box. UE4's networking is great, but it's very focused on a server-authoritative model. We've put rollback into UE4 for games before, but it's a big effort, probably more than a solo developer wants to take on.

Ahh yeah, I had read his post as the rollback and 2.5D graphics being different projects. If you want to do both, implementing rollback in Unreal's going to be a lot of work.

Analytic Engine
May 18, 2009

not the analytical engine

12 rats tied together posted:

if you have a sprite in a 3d world it will clip into geometry at some positions, most notably in the gungeon example, if the walls went straight "up" and the camera was set at the intuitive angle for that shot, the upper half of the sprite would disappear behind the wall when the player was standing underneath it

you can google "2.5 sprite clip" for some discussions about it. I render my sprites as a partially transparent texture on a plane (three.js, not unity), which means they exist "normally" in the world and I don't have to deal with this problem, but as a tradeoff I have to scale their height depending on the camera pitch to compensate for foreshortening

quick example from some reddit thread on this topic:


Cool

I'm new to this thread, do you develop your whole game in JS? I'm looking to make a 2D game using React + D3 or 3D with three.js that runs in the browser or at least an Electron app

12 rats tied together
Sep 7, 2006

The thing I'm working on lately is an electron/browser mmorpg. The client is three.js, electron, and plain old javascript. Server side is python because this is just a hobby project and I already had expertise there, and the netcode is some approximation of deterministic lockstep running off of json and websockets.

I like electron a lot, when I started this project I had almost no front end web experience and electron was the least painful thing to pick up. Chrome dev tools are great, debugger and profiler are great, web workers are fantastic, but most importantly, electron turns every question you have about UI and styling into a trip to the MDN website which is one of the best technical resources ever created by humans. Three.js is also a really good library with amazingly high quality documentation and examples, and has a dedicated community of people who extremely know what they're doing which is important because I do not.

The worst part was figuring out the arcane ritual that electron wants you to perform so that you can import js modules, but, this is only a problem for me because I refuse to use webpack or any other type of bundler.

Overall electron has been great, I have no regrets, and I haven't run into any huge progress impediments due to any of the tech choices. Would recommend.

KillHour
Oct 28, 2007


12 rats tied together posted:

The thing I'm working on lately is an electron/browser mmorpg. The client is three.js, electron, and plain old javascript. Server side is python because this is just a hobby project and I already had expertise there, and the netcode is some approximation of deterministic lockstep running off of json and websockets.

NGL, when you didn't say node, my eyebrow reflexively went up incredulously.

12 rats tied together
Sep 7, 2006

For the server? It uses node's event loop, so it's fast enough despite being python. :)

Part of the fun was going to be watching it fall apart under load, and learning from that experience, but I have struggled to really pressure it without doing things that would be equally bad in any language.

Analytic Engine
May 18, 2009

not the analytical engine
have you used A-Frame for browser VR?

leper khan
Dec 28, 2010
Honest to god thinks Half Life 2 is a bad game. But at least he likes Monster Hunter.
Playing around a bit with tilengine. I really want to like it, but it made some very bad decisions to enable the use cases I want without wasting tons of resources.

I was able to port my dead console stuff to PC with it in less than a day though, which was neat.

Considering forking the thing. But it's not causing huge problems in the immediate term given how much RAM computers have..

Ranzear
Jul 25, 2013

Written in C and can't SSL cert their website. I'm already not sure I want to dig deeper.

Incidentally, any takes on Bevy yet? Comes to mind as a comrade has working with its tilemap plugin. Love me some Rust but still rolling too much of my own netcode model in it to lean into some existing engine.

sailormoon
Jun 28, 2014

fighting evil by moonlight
winning love by daylight


Ranzear posted:

Written in C and can't SSL cert their website. I'm already not sure I want to dig deeper.

Incidentally, any takes on Bevy yet? Comes to mind as a comrade has working with its tilemap plugin. Love me some Rust but still rolling too much of my own netcode model in it to lean into some existing engine.

I'm curious about your netcode and would love to hear about it! I've been experimenting with WebRTC and rollback netcode and it's been pretty fun, but kind of difficult to find write ups on what "feels good" to a player.

roomforthetuna
Mar 22, 2005

I don't need to know anything about virii! My CUSTOM PROGRAM keeps me protected! It's not like they'll try to come in through the Internet or something!

sailormoon posted:

I'm curious about your netcode and would love to hear about it! I've been experimenting with WebRTC and rollback netcode and it's been pretty fun, but kind of difficult to find write ups on what "feels good" to a player.
Congratulations, WebRTC is a real arsehole. Have you got the whole mess working, like a direct-ish connection between two players even if one of them is using a phone connection? (i.e. all the stun/turn/lobby code working.)

Ranzear
Jul 25, 2013

Was looking into WebRTC recently just to have a UDP backend and eeeeeeeeeeeeeeeeeehhhh. It's really hard to not just use websockets for everything.

I had a concept a long while ago of a 'revolving host' sort of P2P networking model, where game authority was delegated to a trio-ish set of peers with the most stable connections, each of them having authority for one game tick/update and if too many other peers disagreed with the game state it would blacklist that peer from authority and find someone else. Basically peer-to-peer anticheat. WebRTC would be amazing for this but the whole thing would also be a complete loving nightmare for little benefit or application (not stable enough for mobile for instance, as noted above.)

sailormoon posted:

I'm curious about your netcode and would love to hear about it!
I'd never shut up about it if it meant I never have to actually write any of it :negative: Currently it's all a mess as I scrap probably everything to just go with tokio like I should have in the first place. I was trying to run tokio-tungstenite before I'd fully grasped async stuff in rust and had to go on a wild side tangent of trying several other async libraries before realizing I was using the 'good' one in the first place.

Here's a gist though. My entire engine is split into server and client components. The server handles all game logic and the client is strictly taking serialized updates for display. This model will even apply to running in a 'local server' mode for single-player games. The client is entirely agnostic to game logic, instead taking simple UUID'd things that have 'for the near future' display properties (asset foo, at x y z, moving to x2 y2 z2 until +n ms or next update, playing animations y and z, blended at playback states k and j, you get the idea). All the client really does is blend or lerp or whatever between updates (at a relatively high tick rate, mind) and regularly send back an input mapping (stick1 x y, stick2 x y, a b c d etc.). The UUID (really just some random bytes) lets the client update already displayed stuff instead of regenerating everything fresh, not so high concept as the rest as caliber already did it.

On the server side, game logic runs at a fixed tick rate but retains 'past' state while it generates two ticks forward. The 'present' tick is serialized as the current state and the 'future' tick gives the small amount of simple forward prediction for half of the latency correction concept. The other half is reapplying input maps to past or even past-past state based on latency which I suppose is a rollback model but is done very intentionally every full tick. It doesn't do any precise tick splitting on input timing but that could be an option for very simple but high precision stuff like fighting games and would let the overall tick rate be way looser which lends to better display at higher latencies (caliber is still a great guinea pig for this stuff). Five temporal states might be a bit much for an RTS or something, but that's a good case for just turning rollback off, so simple configurability of the state model and latency correction is also a big consideration.

The entire thing is the ultimate tirade against anyone tying display to logic or vice versa but the big idea is I can make a very lightweight but functional client but also publish the API without any game logic needed if someone wants to make a fancier and cooler one, they just read the display objects and send an input mapping and very very few things should ever break across that boundary on changing anything serverside assuming it knows how to find new assets and stuff.

I guess the entirety of the netcode part of stuff is just 'serialize poo poo and shove it through a websocket' but this concept of genericized forward-sim does fall under that term.

Ranzear fucked around with this message at 23:21 on Jul 8, 2022

12 rats tied together
Sep 7, 2006

Ranzear posted:

Was looking into WebRTC recently just to have a UDP backend and eeeeeeeeeeeeeeeeeehhhh. It's really hard to not just use websockets for everything.

Yup. I came to this same conclusion very quickly as well.

In my case, I'd still like to write a UDP backend, but I'll limit it to the electron client version only where I can spin up a different process to handle it, and then also not have to implement it in javascript, which means I can justify experimenting with other, more compact, serde formats.

Ranzear
Jul 25, 2013

12 rats tied together posted:

Yup. I came to this same conclusion very quickly as well.

And it's especially true if you're writing latency-correcting netcode. If you're already handling 30-150ms latency, correcting for small latency spikes as TCP corrects dropped packets is nothing.

Websockets also just have tons of wonderful tricks like having haproxy serve SSL on 443 and watch for the ws upgrade and terminate SSL before rerouting to the websocket app. The server app doesn't need to handle any SSL stuff (even with letsencrypt, better to let something else handle certs), browsers support WSS just fine and other stuff should support it, meanwhile your game traffic just looks like a very extended HTTPS connection to any curmudgeons wanting to block games on their network and all your game traffic is encrypted even if they suspected :science:

Ranzear fucked around with this message at 01:09 on Jul 9, 2022

leper khan
Dec 28, 2010
Honest to god thinks Half Life 2 is a bad game. But at least he likes Monster Hunter.
Last time I checked (several years ago), UDP got dropped at a higher rate than TCP. So disabling nagles on your TCP stream could lead to better throughout than UDP anyway.

UraniumAnchor
May 21, 2006

Not a walrus.
A couple of months ago I took it upon myself to learn Vulkan and port an old mobile game from OpenGLES1, and after wrestling with OSX's frozen OpenGL4.1 version, (and by extension, iOS being frozen at OpenGLES3.0) think I'd like to try and port it to Metal, too.

The two guides I used the most to learn the basics were:

https://vulkan-tutorial.com/
https://vkguide.dev/

Are there similar quality guides for Metal? I've looked through the official Apple documentation but more references are probably only going to be a good thing.

xgalaxy
Jan 27, 2004
i write code

UraniumAnchor posted:

A couple of months ago I took it upon myself to learn Vulkan and port an old mobile game from OpenGLES1, and after wrestling with OSX's frozen OpenGL4.1 version, (and by extension, iOS being frozen at OpenGLES3.0) think I'd like to try and port it to Metal, too.

The two guides I used the most to learn the basics were:

https://vulkan-tutorial.com/
https://vkguide.dev/

Are there similar quality guides for Metal? I've looked through the official Apple documentation but more references are probably only going to be a good thing.

Only thing I know of is https://metalbyexample.com/the-book/
But it’s pretty old now. And it’s a book not a site.

lord funk
Feb 16, 2004

Can confirm that Metal By Example is the way to go.

Adbot
ADBOT LOVES YOU

CH Science
Sep 11, 2019

I have a kind of broad maybe dumb question that all my googling hasn’t really landed me a decent answer on.

I’ve got a multiplayer looter-shooter thing I’m working on. I can run the server, connect clients to it and they can run around and shoot each other and gather items that then get stored in a persistent database. So far so good.

But say I wanted to introduce matchmaking, or more generally not have to manually run the server before connecting clients: it’s not like I can have infinite games running off of one server to handle infinite capacity (the server as configured IS capable of more than one game at a time, up to 5 or 6 before performance takes a hard dive), so how is this kind of scaling generally handled? If I were willing to run this peer-to-peer I’d just have the matchmaker pick a player to act as a server and all would be well like the games of yore, but it’s 2022 and plenty of games are doing dedicated on-demand sessions and server-authority is kind of important given the persistent nature of these games and the cheaters they attract.

The way I envision it is thus:

Matchmaking/persistence server runs all the time, probably only need one of these since it’s basically just a big array of connected player info and access to the database

Game client requests a match, matchmaking does what it does and finds 11 other players to start a session with

Matchmaking server does ???? to make a gameplay server spin up out of the ether, sends ip:port and any other necessary info once it’s ready to the clients

Newly ????’d gameplay server receives the connections and starts the game session, when it’s over it relays any necessary persistence info back to the matchmaking server to slap in the database, then kills itself

Rinse/repeat as necessary to handle all the games being requested


So I guess my question is what do I replace the ????s with to make this a reality? AWS Gamelift or some other back-end-as-a-service? Straight up terraform infrastructure as needed and leave servers up to handle additional games after the first one is over, destroying them after a set time with no connections? All my research leads me to services that promise to do the heavy lifting but I can’t seem to find any “this is how we built the multiplayer matchmaking of the latest call of duty” type write ups that really explain HOW to set the stuff up and have it not cost a bajillion dollars in compute.

Thanks and also sorry for the text wall

TL;DR: how do I make servers appear magically when needed without exploding my bank account?

  • 1
  • 2
  • 3
  • 4
  • 5
  • Post
  • Reply