Best way to manage scripts in your project ?

Hey guys, hope you’re fine :slight_smile:

Okay so I’ve started a project and it get bigger than excepted, so I’m asking my self what is the best way to manage script ?

In other words : Do you think it is better to keep for example the “Ennemy” scripts with the Ennemy GameObject ? Or should it be better to have like “GameController” Scripts attached to an Neutral GameObject ?

I was wondering for exemple if it would be better to hold all damage calculation in an neutral script, to avoid confusion between the involved GameObjects when modifying their scripts.

Any idea ? Many thanks !

Use namespaces to organise your scripts and classes.

If you have an Enemy with distinct behaviours, try to seperate those out into classes in their own right. For example.

Inventory.cs
AI.cs
Navigation.cs
Movement.cs

All have their own responsibility. Move them into a namespace such as

namespace MyGame.Characters.Enemy
    public class Movement

namespace MyGame.Characters.Enemy
    public class Navigation

Try to identify logical components and make classes out of them. Don’t just have one class called Enemy and stuff all your logic into that.