what's worse for update the function

Is it bad for performance to have multiple scripts calling something in the update function, or is it worse to have one script with a lot of things in the update function.

I’m thinking about how to go about an fps sscene where bullets are instantiated, another player gets points, another player dies and texts are displayed and so on.

Note: Of course some things cost more performance, but I don’t want to over-think this.

Obviously, the more Updates you have, the more expensive it get. BUT!!! This is trivial, a method call means stacking a few variables to be retrieved later when done with the method and ths means nothing to be scared of.

What you need to consider is that if you pile up all your code in one Update, you break the principle in which a script does its own thing. It also means adding a script to an object is no longer enough, you also need to reference it somewhere else to make it work.

It is like having the Transform class added to an object, but you still need to create a new script to make it run.

As for Find method either in one or in 10 different scripts, it is same to do it 10 times every frame in one place or one time every frame in 10 places. Best is to do it once in 10 places, in the Start.

As a general tip, do what makes the code easiest to read an understand. Get it working correctly, then if performance is not acceptable, use the profiler to find out why and fix as needed. If you try to optimize early you’ll often end up with poorly written code that isn’t any faster.

There is a certain amount of overhead for each script instance, but it’s not huge. It will probably come down to the total amount of work being done. I would use multiple scripts, breaking it up into logical divisions that make sense for your game. Much better than a giant script that tries to do everything. Go for readability and flexibility first.

Well. It depends upon the game play mechanics. It will be expensive to update multiple static variables in update function.

For instance, if you reference a script directly by calling it using Find game component in update function, it would be very expensive. Instead you can make a reference in Start function and call it when needed.

For your FPS scene, certain variables you can make it as static and reference it through other script, it should not make it too worse. Also, for instantiating bullets, you can create a prefab and instantiate it, which will not consume more memory. But, you can also create a function to reuse the instantiated bullets rather than destroying it immediately. Again, it depends upon your game mechanics.

Hope this helps.

Useful Link: C# Memory Management for Unity Developers (part 1 of 3)

Hope this helps, Once you start scripting, you can find the way along side. Good Luck.

GameObject.Find in update is a really bad thing for your game. Try to avoid it at all (it is possible using Dependency Injection for example). And I think it’s not a big difference between 10 scripts or 10 calls, except you will see 10 calls in Profiler and you will know what causing FPS problem)

My friend modified this Dependency Injection “framework” and it’s work well