Help With Implementing Client Sided Rendering On To Path Finding NPCs

My tower defense game is more complicated then the standard tower defense. It’s more of an open map without a set path and units are able to walk around. With the units being able to walk around, you can tell that this game might get really laggy, so using client sided rendering is the best option. Problem is how do I implement client sided rendering to my moving units and enemies that use Path Finding Service to walk around? How would the servers “unrendered copy” move around so that the clients copy is able to mimic its movement?

1 Like

You have two options. Saving the units server-side as only data without any representation to create the models client-side and replicate changes, or do something similar, but using simple blocks to represent the units server-side, and then replacing them client-side with the actual units models.

If u go with the second, youll need to fire events to the client that tell it to get those units, delete the blocks, and replace them with the actual model, the first one would be the same but without deleting anything.

Homewer, i really recommend avoiding pathfinding for a tower defense. It is always gonna be expensive and laggy, as it is in every engine. Prefer to find an alternative like a lot of default paths to simulate moving around instead to avoid the performance hit of pathfinding.

Have the server create parts that move by alignposition and alignorientation. Then weld the npc characters to those parts locally.

I’m also developing a tower defence game and I’d recommend using an ECS architecture if you aren’t already and aren’t too deep in development. I’ve found ECS to be a pretty good architecture for this sort of thing since you can just have a single movement system that goes through every entity with a transform/position component and update it and then you’d just send that to the client. The client could have its own ECS world or just keep a mapping of entity id from the server and put a model at the position. Also, client prediction could be useful here? Server sends the position or direction and the client would just “predict” that it’s moving in that direction until the server sends a new update which then the client can correct any mistakes if any.

Really sorry for the late reply. I’d really prefer the first option. it seems way more lag efficient, but I’ve been stuck on how the server changes the CFrame data with the actual path finding (note units have different walking speeds and if I use tween service, it will be buggy on corners unless I make the distance between waypoints really small which will cause alot of lag). Is there a refrence script that you may know of?

Yeah, I figured out path finding for tower defense isn’t a good option way too late, so I’m basically stuck with this :sweat_smile::sweat_smile:

I really like the “ECS architecture” u mention, currently looking into that. But the “Predicting” kinda gets me worried. Thanks for the help!