how many scripts should a gameobject have?

apart from the very basic scripts , what should the average be

i found that several objects, player and enemy have about 11 custom scripts each , is this too much ?
cause i know a few will have to up to about 16 ish
is there a problem with so many scrips

It shouldn’t matter too much how many scripts you have. The thing that will kill your processor’s speed is how many “Update” functions you have and the complexity of the code in those update functions.

If a script doesn’t use it’s update function, delete it from the code.

I’m making an fps, and I personally think it wouldn’t be ridiculous to have 30ish scripts on one player. The idea behind a script is organization. If you want your code to be easy to read, it would be better that you segment it as much as possible (so long as it’s still convenient).

For instance, in my game I will eventually have all of these:

  1. Rotation script (Done)
  2. Movement script (Done)
  3. Parkour initial checks (Done)
  4. Parkour script/Mantle (WIP)
  5. Parkour script/Vault (WIP)
  6. Gun Controller
  7. Gun#1
  8. Gun#2
  9. Gun#3
  10. Gun#4

Tips: Optimize your code by caching variables like transform (var trans : Transform;).

Tips: Use coroutines instead of update for functions that don’t need to be called every millisecond of existance.

Tips: Lastly, don’t do stuff you don’t need to (this may seem obvious, but I have plenty of unnecessary code atm).

Look up “Optimization Unity3d” on Google and you will learn a LOT. Especially if you type in Optimization Unity3d iPhone/Android, but if you are making a FPS don’t apply any iPhone/Android optimizations, assuming it’s a pc game.

There shouldn’t be any problems with many scripts attached to game objects. Especially when you have objects like player that are central to your game.

However, if you feel that you have too many scripts, it is worth to check if maybe there are some things that can be regrouped. Also you might confuse yourself in the exact order of execution of the scripts and that can be a pain.

But it’s ok none the less.