game scripting management

Hey there,
I’m a beginner programmer, i’ve started using unity since something like 6 years ago but, i’m still a newbie because everything i know come from experiments i’ve done in unity…
anyway… i’ve got a question for you experienced programmers that are reading this from the height of your knowledge:
while making a game, is a good thing provide an Object that is a sort of center of the project? i mean something that you can use as a “stat menager” like a game master that knows everything? or it’s better to let every object communicate with all the other gameobjs that he need???
thanks in advance to who will spend some time for this dumb question
Lautz say bye =D

I think this is an open ended question that really is answered by:

What you need to use, is what you need to use.

Some games require a centralized state controller (like a turn based game) others require that game objects talk to a centralized host. (like a mmo) and yet others require open ended communication between objects.

There is no one size fits all solution to this.

1 Like

Not entirely sure what you mean, but things like this usually depends a lot on the size of your project. For me personally I do use what you could call a “central object”, in that I have a Script called Game Manager that is alive the entire game (singleton), and through it I get things like Game State, start my game, load/save. General things like that.

For my project that works great because it’s fairly small. Some people like singletons, others don’t. If you don’t want that you could look into dependency injection.

2 Likes

The question is pretty vague, but here is some generic advice.

Its good to have some managers in the scene as required, but better if you can make static managers that don’t have to exist in the scene and can be initialized safely with minimal scene references.

If two objects must communicate, it’s generally done with collisions, triggers, raycasting or some kind of lookup - maybe through one of the managers.

Two things shouldn’t communicate unless it’s absolutely unavoidable.