C# instantiate/ script efficiency question...

Hi,…I hate making this it’s own thread but I dun wanna hijack anyone either.

My question is simply,…I have a character preFab. With a movement behavior script on it.

I want to instantiate several of them and watch them run around doing their thing.

BUT

Now I have several prefabs running around each with their own identical script. Is that wasteful?

Should I instantiate a plain preFab with no script,…and add at runTime?

Better yet,…do I not add any script and only have One Movement behavior script attached to some scene Null, that Finds and drives them all?

thanks!

In my opinion it is a lot easier to have a script for each moving object. While I am not 100% sure that it is smarter to have 1 master control script vs a bunch of scripts that handle each of the objects movements I can say that the master control script will only be running 1 update loop vs x number of loops but the 1 loop might be bigger if it’s constantly updating other objects so it might not be optimal either. My advice, make it easy for you and adjust it if you need to. No need to over complicate things if you don’t have to. I would suggest to you object pooling vs instantiate/destroying game objects.

If you intend to have less than 100 on screen, I wouldn’t worry about it even for mobile platforms.

Way less,…prolly at most 14 : ) and yeah , for Mobile.

Once instantiated they never Destroy or Birth, not like bullets or something…They are Hockey players,.( see video in sig , if curious)

Thanks all,…I had my suspicions that I was being overly anal,…but it was killing me so I had to ask! Thanks,…

:slight_smile: