#Tons of Enemy NPCs: Content Streaming or Generate on Client-side???

1 messages · Page 1 of 1 (latest)

frail mica
#

Hi.

My game generates around 200-300 Enemy NPCs around a very large map - all currently generated by the server. Should I switch to using Content Streaming or should I generate all of the NPCs client-side?

My goal is to create a lag-free experience from some of the more cpu/gpu intensive game action. I have already written a large portion of the Enemy NPC code and I prefer not to rewrite it.

I was in the beginning stages of rewriting all of the Enemy scripts to make them client-side generated (which is causing me major headaches). However, I came across Suphi's remarkable 'Content streaming' video which really opened my eyes to a solution that's possibly easier to implement.

I have a few questions about using Content Streaming vs Generating NPCs on Client-side:

  1. Is using Content Streaming a viable solution for generating the NPCs on the server while also reducing the impact on the server?
  2. I read a while ago that when using Content streaming, you must write all of your code with the 'WaitForChild' method on ALL instance references. Is this the case?

Thanks in advance!

smoky coral
#
  1. The load on the server will not change if you use content streaming because the server sees every instances.

  2. You don't have to use WaitForChild on every instances, you can use CollectionService's GetInstanceAddedSignal and GetInstanceRemovedSignal.

hot lodge
frail mica
#

Oh. I assumed that if it didn't have to stream the NPCs to players out of range that this would reduce the load on the server.

So then the best solution is to generate the NPCs locally?

paper laurel
hot lodge
#

because if your doing a magnitude check then you could just spawn in npcs close to each player and don't spawn in enemy's that are not close to players

#

i like the per player npc system

#

each player can spawn 10 npcs

#

and these 10 npcs stay close to that player by de-spawning as they walk away and respawning as they get to a new area

hot lodge
frail mica
# hot lodge content streaming will reduces the network load but not the cpu load if the serv...

Ok. Thanks for the follow-up. I think I'll implement both, but I see a few issues with Content Streaming...

*In my existing script, players can destroy objects (big rocks/minerals) for loot. Loot is generated each time part of an object is destroyed. I noticed that ContentStreaming [Oppurtunistic] is triggering the DescendantRemoved method on each rock whenever it is removed from the sight of the player. Is there any way to detect if ContentStreaming is removing the item, or do I have to manually check for distance each time an object is removed from sight?

hot lodge
frail mica
#

Hmmm... Let me rethink this...🤔

hot lodge
#

does the server set a attribute or somthing?

frail mica
#

Loot is determined on server using a Loot Plan chance system (Remote function)

#

I'll check the flow and tell you shortly how everything is triggered. I haven't worked on that part in a while

hot lodge
#

well maybe you could tell them in the remote function instead of the DescendantRemoved event

south wyvern
#

hmmmm

#

my way is

#

if the npc too far then don't load it

south wyvern
south wyvern
#

like

#

if there's no player in Zone B then remove all of the NPC in Zone B

#

also I would go with Content Streaming because if I generate it on client side then it is not easy for server to manage something on client