Context - My project is a competitive game where 8 players, in a free-for-all, send waves of units at each other. Players can build lots of defensive buildings shooting projectiles - tower defenseish. The pathfinding is all done on server via 8 different grids. From the mid to end game pathfinding is very predictable and infrequent. So unit movement is very predictable. Replicating frequent movement with 1600 units is too much, even when serialized and package tightly.
Here’s what I’m thinking:
Have server continue to process pathfinding
Also give players data to pathfind, smoothing unit movement locally
From server, periodically replicate the unit position + 5 tiles ahead
Also calculate player ping
From client, Based on the delay, imperceptibly increase unit movement speed over those 5 tiles to catch up to server
How much wonkiness can you foresee with this approach? There will also be a ton of projectiles. I just don’t know how else to do it with this many units. I feel like there is an answer close here esp because my paths dont change that frequently. How does Age of Empires 4 replicate pathfinding on 1600 units when pathfinding changes very frequently? Any input would be helpful.
Actual pathfinding is often overkill or even unwanted, in that the waves of things attacking are better off actually attacking through barriers on what is otherwise the best path, based on static features, you know … lanes or what have you. If someone can build across a lane and block it, do you WANT the units to actually turn around as a line of lemmings and start going through the woods to the other lane?
All that asside, id think that individual units would not have paths, the path would be for the spawner and inherited for everything it spawns, or be for the entire lane (to the destination, target of attack, homebase, etc) and would be super cheap to network it.
Most units sent cannot attack and paths cannot be totally blocked. With that said the pathfinding has to be dynamic as there are indestructible actors placed by players in real time. My pathfinding is custom built and as lightweight as humanly possible for the project. This isn’t the issue.
EDIT: I should also add that the server can handle 1600 units pathfinding at once with projectiles everywhere.
My issue is replicating unit position of up to 1600 units at once /w projectiles flying and keeping it smooth and in sync on the clients.
Thanks for taking your time to join the discussion
I am a professional by the way. I made a hex-grid rts with player controlled unit pathing.
Also, i don’t see the problem with networking thousands of positions, that sounds normal. It is up to you to decide an appropriate frequency to send them.
So, if you have thousands of units, id assume their positions are getting networked at some frequency already, right? Then you don’t even need to network the paths.
Alternately, if its your paths that have the thousands of positions, well you need better path encoding that has fewer (ie, north 5, east 1, north 25). Also, like i said before share paths between units, and only send the path once or when it changes.
Re: it sounds to me like maybe the overall path from spawn point to the destination is not changing much, its only sections along it where a player may have built something, which needs to be passed through. So, for that section, have it network for each tile, how close it is in steps (considering obstacles) to being past the section. This would be recomputed when obstacles change.
Oh I’m sorry I didn’t mean to imply you weren’t a professional. I was just asking for other opinions. You can never have too many different perspectives on an issue to open your mind up.
So the pathfinding is A* with unit grouping, leader following, partial path recalculating, and tile grouping for large sections without obstructions. Units follow a master path when spawned if something is placed over their future path then its recalculated. It’s run on a separate thread. It’s lightning fast.
I’m just having trouble replicating 1600 unit positions /w tons of projectiles and keeping the movement client side accurate & smooth. Any suggestions? I think I’m struggling to understand how to smooth movement on the clients without having more of the path than just each position update.
Yes, they are being networked twice a second at the moment because I was thinking about moving the pathfinding to the client so they have the entire path to smooth out all movement
THIS is something i have overlooked! Thx so much. I currently have arrays of int points. I was trying every which way to serialize this list of intpoints and package them as tiny as possible, but This is the answer. It can really simplify the data. I’m an idiot.
1 straight line down a 100 tile path could be encoded as simple as a 4 digit int. *slaps forehead