Roblox Real Time Strategy Game Unit movement solution

Please do not ask people to write entire scripts or design entire systems for you. If you can’t answer the three questions above, you should probably pick a different category.

Over the past couple weeks, I have been working on a small project that I am really passionate about. A real time strategy game inspired by games such as Age of empires and age of mythology. Now, there are a few problems that I just do not know how to solve and the last one is such a large issue that I am honestly considering giving up.

Issue 1: unit movement client to server communication. So, currently, I have it so that when a player selects one of their units client side the unit gets added to their unit selection table. Players can have many units selected at once, and so when they press right click and there are units in the table i fire a remote even to the server. From there I loop through the table and compute the path to the mouse position, and then I send the path waypoints back over to all clients as I want to handle movement and visuals of every npc on the client to reduce lag. So is there any other way to get the info over to the server as i do not want to be firing a remote even so often.

Big Issue: How do I move the npcs without using :MoveTo()? People keep telling me that if I use :MoveTo() it will completely shred performance and so what are the alternatives? The ones I have seen are tweening and lerping and they seem so terrible. Anyways, are there any good solutions that have the same effect as MoveTo()? And why is MoveTo() so bad? Wouldn’t Roblox not remove it if that were the case? Anyways, here are some screenshots from the game so far

Under the assumption you’re firing one remote event per unit, you could change it around to fire one remote event with the information on where to move the unit. Otherwise, seems pretty good to me.

I’m not too experienced with :MoveTo(), but it works for when you have under 30 or so NPCs. The issue is when you have a RTS or Tower Defense game where you might have up to 100.

The best way to improve preformance would be to have the client run their own version of the NPCs. Basically, you’d replace the server-sided NPC with a grey brick that has a humanoid while the client creates the actual models on their side. This reduces what the server has to replicate to the client by a massive amount.

Depending on how your game works, you could remove the server-sided NPC entirely and replace it with a couple of values: it’s position, where it’s moving, and how long it will take to get there. From that information, a client could figure out where the unit is supposed to be and move it accordingly. However, this might get very complicated if you have things like knockback in your game, but it would definitely work for something like The Conquerors 3. But you’d still be using :MoveTo() on the client, unless you made a whole custom movement system.

Not per unit, rather per selection. So I fire a remote event with however many npc’s are currently selected by the player whether that be 1 or 30. So on the client when a player selects a unit via left click, it gets added to a table and if they hold shift they can select more units with left click. Then I fire one remote for all the npcs in the table.

For the other thing, you can use MoveTo() on the client but I am not sure if that would make it less performance heavy.

Usually the client can handle whatever you throw at them, but you need to lessen the load of the server as much as you can.

something like this has been on my mind recently, basically having an imaginary npc :moveto waypoints it computespath and each waypoint assert physics formulas to determine change in positioning and relay to the client these position changes.

Ive held off on it b/c its more of a after thought (and definitely only want to do it after the main server sided system is done)

my question is, have you actually stressed test 100 npcs moveto? I just did and yea it does impact performance (alot of net receive is not a good thing)

so if you feel up to it and reached some part of development that you feel necessary for doing it then ya, definitely give it a shot

heres placefile of what i got so far could help upstart you
ImaginaryNPCMovement.rbxl (94.8 KB)

I have many questions about it, should we send to the client the waypoints?, seems to me so
should we also keep track of the current position on server? yes but how much should we trust the client to visualize properly i.e. lets say you are actively moving an NPC , lets say client somehow gets the npc lagging behind the actual expected position what the heck do you do? teleport it? idk it just seems really convoluted which is why I dont even want to attempt this myself just yet.

perhaps this would help you