Jump to content

Optimizing question


Alienhead
 Share

Recommended Posts

I'll try to paint the scenario. Say I have a rather large city I'm constructing.  I'm using Navmesh very lightly to update goto positions periodically.  I have about 10 cops that patrol the city on foot.  and about 30 citizens that wonder around. Here's my question regarding optimizing:

Would it be best to run the Ai script on each object independently ( just attach a script to the cop/citizen ) or construct a main logic function that handles the cops/citizens within a single control loop?  What is the price of running 40 character scripts VERSUS one main loop that controls them all ?  I would rather have them running independently but later down the line if it proves to be more optimized running them in a control loop I'd go that way.   

Just wondering if anyone else has faced this question before and If you had any feedback? Thanks.

Link to comment
Share on other sites

That should be fine without any special code. Just don't do everything every frame. Each AI doesn't need to constantly re-evaluate everything they are doing, instead expensive checks should use a delay so each one only gets triggered once over an interval of frames.

  • Like 3

My job is to make tools you love, with the features you want, and performance you can't live without.

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...