❄️🎁⛄ The Winter Games Tournament is Live! 🎄🎅❄️
Jump to content

Recommended Posts

Posted

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.

Posted

I don't know for sure - but the loop seems faster to me than heaps of scripts.  LUA is slower than C++ so I would think the less Leadwerks has to go back and forth between calliing a script the better.  Somone else may have a more definate answer.  :)

  • Like 1
Posted

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

Let's build cool stuff and have fun. :)

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.

×
×
  • Create New...