so im moving a npc on the server which costs network receive since it replicates it to the client and raises the receive, even if you delete the npc on the client it doesn’t lower the receive cause its still trying to replicate, whats a alternate method I can use
Assuming you wan’t the NPCs to replicate but want to decrease the network bandwidth, there are a couple of methods to do this:
-
Consider not using humanoids if not needed as they are expensive to maintain and replicate (humanoid states, humanoid physics, etc.). For example, if you have a bunch of NPCs that only play animations, you can use AnimationControllers instead.
-
If you really want / need humanoids, you can decrease the amount of maintenance that humanoids do through ControllerManagers (character physics controllers). You should read this announcement post too, has a ton of details!
…and whoops, side note! Development on character controllers have been slow/delayed, so keep that in mind if you want to use it. You may or may not face bugs, you can keep an eye on the announcement post for updates.
-
BEST PRACTICE! Sometimes, Roblox-handled replication just isn’t enough (especially for games with a hordes of NPCs), you can look into custom NPC replication instead. It is commonly used for RTS games, and it is a bit tricky to setup but the received network bandwidth dramatically decreases.
You can read this very good post by @Atrazine and/or my compilation of tips and tricks for custom replication performance (which also has extra links to other helpful resources).
Custom NPC replication works like this:
- Pathfind + send position data for NPCs on server (rather than placing actual models and humanoids and letting Roblox handle the replication)
- Render position data for NPCs on client
However, if you ever want to just, not replicate the humanoids to all clients for some reason, put them under workspace.Camera. Instances placed under there will not replicate at all, you can test this yourself.
You can pathfind without actual models in workspace?
Also if you try to :Moveto on humanoids under server camera it doesn’t seem to work well
I mean all you need are your starting position and target position, then PathfindingService can generate waypoints for you. Here’s a hypothetical way you could do custom NPC replication:
-- server
local RNS = game:GetService("RunService")
local RS = game:GetService("ReplicatedStorage")
local PTS = game:GetService("PathfindingService")
local npcReplicationEvent: RemoteEvent = ...
-- npcList[name] = {position, waypointArray}
local npcList = {}
local npcPathfinder = PTS:CreatePath()
-- create an npc
npcList["JohnDoe"] = {Vector3.new(1, 1, 1), {}}
task.spawn(function()
while true do
local positionList = {}
for npcName,npcProperties in npcList do
local position: Vector3 = npcProperties.Position
local waypoints: {PathWaypoint} = npcProperties.Waypoints
local nearestPlayerPosition = ...
if #waypoints == 0 then
local computedPath: Path = npcPathfinder:ComputeAsync(position, nearestPlayerPosition)
waypoints = computedPath:GetWaypoints()
else
position = waypoints[1].Position -- set new position to waypoint 1's position
table.remove(waypoints, 1) -- flush out waypoint 1 as its already been reached
npcList[npcName] = {position, waypoints}
end
end
--[[
you are recommended to batch your remotes because
each remote fired costs network bandwidth,
e.g. 1 remote event will be 10x less network than 10 remote events
]]
npcReplicationEvent:FireAllClients(positionList)
task.wait(1) -- move to next waypoint
end
end)
-- client
-- create the npc models on the client, and then...
RNS.RenderStepped:Connect(function()
-- loop through the received positions, interpolate (:Lerp()) the npc models to those positions
end)
I also want to point out that for hordes, usually people use flowfield pathfinding or other alternatives. I wrote about flowfields, more info can be seen here.
These controllers are very unfinished and are pretty much abandoned so I don’t recommend using them
Oh seriously? What does it lack from humanoids, are some features missing, broken, etc.? I’ve honestly never tried it so I don’t know.
it is FPS dependant, lacks features which were supposed to be added, but were not and in the post they stated that it’s not gonna be worked on anymore for some time (It’s been almost a year)
Using server authority should prevent recive of humanoids from client entirely but if your game uses custom character movement it has to be adapted
that’s not how server authority works ![]()
That literally how it works
It only listens to remote events and input binds parented to player
I literally wrote own player controller from scratch to be server authority compatible
you will still have the humanoids replicated to the client😔
OP was talking about recive from client
Are you dyslexic?
![]()
[spoiler] [/spoiler]
[spoiler] [/spoiler]
are you Yarik from the Yarik
theory ![]()
In addition to this, it’ll be very nice to specify to play and load animations only on client
What is the Yarik theory?
I only know The New Luau Order Evil.Inc
So is it possible to do this or no
Well in this case id hope that there would be no actual npc models moving on the server and i can handle all their positions on the backend and just send them to the client but then the npcs wouldn’t be able to like “bump” into each other
That there is more than 1 Yarik™ operating the Yarik™ account.
I’ll make a post about it soon
This would be the thing you’d use but that’ll only work if you don’t want any client to have that replicated
but my humanoids arent moving in there using :moveto