Okay, I narrowed the lag down to the enemies loading. With r6 enemies, it can handle thousands of enemies at once. Also, when there are a lot of enemies, they start glitching around. Same if I change the speed.
Try my edited client code. I clamped the deltaTime.
they still glitch around when i change the speed. When i change the speed, they just glitched off the map and damaged my base.
Like as in they go backwards or something? I donāt get what you mean by glitching.
like they just fly around, then go back to the track.
Sorry for asking to send so many videos, but could you send a video of what it looks like?
You havenāt changed the refresh_rate and deltaTime multipliers right?
Also:
My formula for distance was wrong, try my edited server and client code.
Yep, it works pretty well now. It still is a bit laggy tho. How could i optimize it more? Should i use actors?
You could try to use Actors but first off, you can try to create the objects only on the client, which should help with performance. It would also allow for streaming enabled to be turned on, further increasing performance.
Iāll try to implement this, wait like 5 minutes.
Finished implementing the above, try my edited server and client code. Iāve also implemented BulkMoveTo.
There is a crucial thing you have to do though, and itās moving the ServerStorage.Enemies folder to ReplicatedStorage.Enemies. (AND IF POSSIBLE, re-enable StreamingEnabled)
To know that itās working, it should look the exact same on the client, but on the server, you should not see anything.
Also, just asking because I may be able to do more optimizations, do you plan on switching the map in the middle of the game? And if you do switch the map in the middle of the game, are you destroying the old one?
It works pretty well, but the loading is still really laggy.
Could you answer the questions I posted? Is it also working better than before (specifically the loading)?
Could you read through my reply and make sure you did everything like turning on StreamingEnabled?
Also, thereās a point where no matter how many optimizations we do, it wonāt be better. Like for example, if there are 2000 enemies, then obviously if your hardware isnāt good enough, thereās no way to make it run smoothly.
Sorry for the late response. Yeah, streaming enabled triggers the cut corner glitch, so that kinda sucks. One thing I noticed though is that the X axis offset only works sometimes. How can I fix that?
@Katrist
Ok soo iām working on similar system, and me and my friend used linear interpolation and some replication, we have enemies as module script with pure math and variables that lerp to points. Then we replicate position to client where animations and effects are done, itās hard but it donāt lag much
Turn StreamingEnabled back off and tell me the answers to these
Another video would also help.
This is pretty much the same way Iām implementing it. How much enemies are possible with your system? Iām pretty sure the goal is for at least 500 enemies to run smoothly.
Also, for your spawnenemies function, get rid of the coroutine, we already have one in the function itās calling so it isnāt needed.
Your current code:
local spawnthread = coroutine.create(function()
enemy.spawn(name, nodes, exit, enemyspawn.CFrame)
end)
coroutine.resume(spawnthread)
task.wait(math.random(0.2, 0.3))
Fixed:
enemy.spawn(name, nodes, exit, enemyspawn.CFrame)
task.wait(math.random(0.2, 0.3))
Actually, they work pretty well with 1000 enemies, after i switched the rig type to r6.