Jump to content

AI and FPS


TattieBoJangle
 Share

Recommended Posts

AI is killing my map not sure why i get 500fps i then add 10 zombies from the dlc and it drops to 50-60fps

this is with them standing Idle as the range is small and when they chase it drops a little more :/

 

The above is with a pivot and a camera 50-60fps

Using prefab player 80-90fps

Asus Extreme v x99, Intel I7, Windows 8.1 64 Bit, SSD, Geforce GTX 980 4GB, 16GB Ripjaw DDR4

Link to comment
Share on other sites

You can try and make the GetEntityNeighbors.lua more efficient for your usage.

 

The callback function WorldGetEntitiesInAABBDoCallback(entityextra) will insert entity into the global WorldGetEntitiesInAABBDoCallbackTable.

 

if you let it default it will add every entity that has a script in range of the current entity into the table, but not itself.

 

Assume your zombies are all in range.

so for 5 zombies the table would be built with 4 zombies 5 times. ie 20 inserts.

for 10 zombies the table would be built with 9 zombies 10 times, ie 90 insrters.

for 20 zombies the table would be built with 19 zombies 20 times , ie 380 inserts.

for 100 zombies the table would be built with 99 zombies 100 times, ie 9900 inserts.

 

So if you select the entiries you need to process, ie you are not interested in members of the same team being added to the table, then don't insert them.

 

In LOSW - LastOneStandingWins I use this

 

function WorldGetEntitiesInAABBDoCallback(entity,extra)

if entity~=extra then

if entity.script~=nil then

--opposing team members

if ((entity.script.teamid==1) and (extra.script.teamid==2))

or ((entity.script.teamid==2) and (extra.script.teamid==1))

then

if entity.script.health > 0 then

-- who are alive

table.insert(WorldGetEntitiesInAABBDoCallbackTable,entity)

end

end

end

end

end

 

so only opposing team members who are alive are inserted. This immediately halves the size of the tables, and other saving are made as the level progresses.

 

Other changes made also considered that I was more likely to target an entity that was close by, so what happens if I set the radius to a quarter of its normal distance. Even fewer neighbours would be inserted, but I was going to pick someone closer to me anyway.

 

So I performed a quick local check, and if that found nothing, I performed the full check. This two stage approach meant that as zombies are fighting, they are typically stood near their opponent. So the first check would return entries in the table. If nothing was found the second check would scan the whole area, and end up chasing another entity. If there was no entities, on the second check then there was a winner.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

 Share

×
×
  • Create New...