Alienhead Posted September 30, 2022 Share Posted September 30, 2022 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. Quote I'm only happy when I'm coding, I'm only coding when I'm happy. Link to comment Share on other sites More sharing options...
SpiderPig Posted September 30, 2022 Share Posted September 30, 2022 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. 1 Quote Link to comment Share on other sites More sharing options...
Genebris Posted September 30, 2022 Share Posted September 30, 2022 One loop is always better but 40 is still nothing so don't bother in my opinion. Do what's more maintainable for you. 1 Quote Link to comment Share on other sites More sharing options...
Josh Posted October 1, 2022 Share Posted October 1, 2022 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. 3 Quote 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 More sharing options...
Recommended Posts
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.