Performance issues with AI controller?

Hey, so yeah, I’ve been noticing some occasional stutter/delayed moving AI’s lately with my AI controller module. Basically what I do is when I create a new NPC, I pass it in to my module script, where it’s then added into a list and that list gets iterated over each millisecond or so by updating an index value + 1 each time, so it goes through each mob and updates stats and so fourth for it.

The code is a bit messy, or large, so I figured it’d be good to make a paste bin of it instead, also the formatting looks much nicer, so here’s the code: local mobs = {}local index = 1local points = game.Workspace:WaitForChild("Mo - Pastebin.com

Further details, I am using the PathfindingService Roblox has to make their movement good and on-track, which has been awesome actually. But just recently, they started to slow down after moving to a point in the path, it’ll delay maybe half a second or so, not sure why. But I did also notice some stutter in Studio test mode later in the game, it’s weird. And all the mobs do get collected and thrown away from the list, and also physically deleted, at the end of each game.

Hope these details clear some stuff up, any help here appreciated. Thanks!

EDIT: I just realized I had a print near the top of the RenderStepped event which was unnecessary, and realized it could’ve possibly caused lag because of constantly sending data to the output, so I got rid of that, but am still seeing similar results.

I’ve encountered this issue aswell using move to. not only moveto but aswell magnitude with the humanoid root part is delayed. This could probably be an server related issue that the humanoid position gets updated some time later. I haven’t found any solution yet. Maybe it would be wise to make an engine bug of this

1 Like

Darn, that’s unfortunate. I mean, I would, but it’s just too much work because I can’t post in certain sections of the forum. Might as well leave it for now.

Thanks for your reply though.

If anyone has any workarounds or different methods I could try using instead that’d be great.

1 Like

Perhaps you’d like to try setting the network ownership of the parts to the server first and foremost? I’ve noticed that there isn’t any network ownership lines here (I used Ctrl + F). One of my guesses is that physics are getting jumpy between clients.

In addition to the above, clients can manipulate those NPCs if they have network ownership, so if these NPCs aren’t rendered on the client-side, automatic network ownership may also present a potential vulnerability in your game.

1 Like

Hm I see, thanks Colbert! Although through out my testing I was the only player in the game, so I doubt that this is why it’s causing laggy and delayed movement, but I will definitely add that anyways, for the reasons you said. I assume it’s just

limb:SetNetworkOwnership(nil)

Right??

Yes, exactly. Nil will pass it off to the server, so ownership won’t flicker between clients (and thus not cause a physics discrepancy). That being said, I’m only having a jab here - I strongly doubt this is the source of the delays. That’s especially given you said you tested it in a one-player server.

May have to look again.

1 Like