Am I saving memory/performance by separating stuff in separate scripts?

Let’s say I have steering behaviors script, a big one that has methods for different behaviors such as seek, pursuit and so on. Do I gain anything by separating those behaviors, seek, pursuit, etc. in separate scripts or not?

Imagine for example you have 100 units and they just need seek behavior, but instead you attach to them this big script that contains methods and data for all other behaviors too. Or maybe it does not matter, maybe it only matters what happens in the update function for each?

Thanks

I would generally say no, but that assumes the scripts have been written efficiently to start with.

I had my engine controller script that rotated all the individual wheels on my tanks. The script was taking quite a chunk of performance percentage wise for the wheel rotations, so I created a script dedicated to rotating the wheels.

The engine script run with a lower percentage, but that gain was lost in the new wheel rotation script, so in the end the total was about the same.

Let’s say I have Seek and Pursuit behaviors.

There are two options:

  1. I can put them in one script like this

//Seek variables

//Pursuit variables

//variables for other behaviors

//Seek related methods

//Pursuit related methods

//… methods for other behaviors

  1. Or I can just put them all in separate scripts

//Seek variables

//Seek methods

Not sure I explained my question well the first time, that is why I reexplain :slight_smile: jlcnz your answer did not answer my question … my bad, did not explain well

Typically, a class’s methods are not duplicated in memory so the number of member variables and the number of instances have a greater influence on RAM utilization. These if they are entirely or near entirely method based might be better as static methods.

As for the files, maintainable code has great value making code you can understand and extend is always a good idea.

arr right… I should really stop skim reading these scripting questions since I obviously suck at skim reading!

In your situation I would probably separate them out. Ive never really dug into performance in regards to what youre talking about.