Client sided Hostiles

Hi, I’m working on a large scale RPG-type game within ROBLOX and one of the issues I’ve come across is multiple Hostiles in game.

Some background on the game:
Players are able to visit Planets in-game, each Planet is loaded Client-Side to improve performance, so the location is entirely determined on the Players where-abouts.

Now, as they’re client-sided, I’ve ran into the issue of spawning NPCs / Hostiles in-game as they are deemed as local and client specific, meaning Players are essentially seen fighting nothing and it removes realism.

I’ve seen posts of people talking about a couple of blocks / humanoid server-side and then the client Hostile is loaded on-top of that for the individual Player. How could I go about doing this?

I appear to be the local experienced custom streaming guy. Let’s talk some more about custom streaming!

Reinventing the Wheel

This is one of the major problems with trying to use local parts to optimize things. Basically, you have this predicament where…

  1. You use local parts for everything, so enemies spawned locally cannot be seen by other clients, BUT
  2. Enemies should be able to be seen by other clients, as well as whatever state they have, AND
  3. Enemies should be simulated on the server to prevent exploiting or other client cheating.

In order to achieve all of the above, you are likely going to have to spin your own custom method of representing your streamed planets in the memory of the server, but without using instances. This means you have the rather colossal task of reinventing the wheel, or in other words, rebuilding some of the functionality we normally take for granted when using instances, like…

  1. State replication on changes.
  2. Collisions, pathfinding, raycasting, and other features that depend on geometry.
  3. Physics, including mass and forces
  4. Anything else you might need that you don’t get.

Now, this is by no means impossible, nor do you have to implement every single thing I stated above. It will, no matter how much you need to rebuild, be a lot of work.

Why a custom streaming solution generally doesn’t provide a tangible performance benefit

Custom streaming will only get you a performance benefit compared to just using Roblox instances in very specific circumstances where…

  1. Your world is really, really big, and would otherwise have to be represented with many millions of parts.
  2. You have gameplay that is simple enough to translate into raw lua data structures, and your programming ability allows you to highly optimize these routines.
  3. You are using clientside parts to alleviate physics load on the server while keeping the game server authoritative.

Please see my other custom streaming post for additional reading on why pulling your own custom streaming is generally not a good idea.

The Moral of the Story

A wise computer science professor once said to me,

Premature optimization is the root of all evil.

While this might be a bit dramatic, I find it often ends up true in most cases. Unless you’re building something that has an incredible performance requirement, its best to avoid thinking too hard about optimization until features are created. You can always optimize clean code, but you can’t always extend optimized code easily.

Edit: experience → experienced

4 Likes