Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
1

Cuttng AI based lag?

Asked by
OBenjOne 190
5 years ago

I have AI tanks and auto turrets in my game which deploy to help the team that has less players on it. I wrote the detection script a long time ago and let's just say it is so long and inefficient and poorly thought out that it is causing serious lag problems in my game. The goal of the script is to detect enemies and bullets fired by enemies inside the Al's detection radius. An idea I have as a replacement for this lag causing script is to place all possible targets in a folder and then iterate through these to find the nearest one inside the detection radius. An idea of how this might work:

 while true do wait (0.5) --check every half second (or less?) to catch fast bullets traveling through the detection radius
  --iterate through parts in the possible targets folder to find one close to the AI tank
  if thispartdistance < lastcheckedpartdistance then target = thispart --later in the script the tank drives to the target and fires at it
 end
 end

I know this script is extremilly quickly drawn up and not even close to functional but you get the general idea. My only fear is that because I will have about 10 tanks and 15 turrets (25 scripts running simaltaniously D:) and anywhere from 10 to 30 possible tangets this method will also glitch out my game. Will this script cause excessive lag? If so is there a better method? I am not requesting a script since it probably would not fit with my game anyway, I just need some pointers on how to combat any lag that may occur from AI like this.

0
Sorry for the title, "your title is not concise enough" OBenjOne 190 — 5y
0
because your internet is laggy FixRobloxz 61 — 5y
0
maybe use local script FixRobloxz 61 — 5y
0
Can you specify how fast the bullets are? like if it's 1000 studs/s then detecting them while they are flying is not a good idea. Instead when a bullet is fired check if it's close to an AI. GGRBXLuaGG 417 — 5y

Answer this question