Is it possible to use SendMessage on a specific Monobehaviour but on all gameobjects in the scene?

Hi!
I am currently working on a game where a lot of my gameObjects are characters for which I need to increase the age by one at the end of each day.
At the beginning I was planning on using my NewDay() function which is called when a new day begins to send a message to all my characters gameobject and increase their age by one, but I couldn’t find a way to do so.
Then I though I could make avery amobject calculate their age base on their “birthday” and the current day but it would be super innefiient because they would check if the day is still the same at each frame :frowning:

Does anyone as a clue?

Hello, create a manager script for this task, in the manager create a event like this

public static event System.Action OnDayChanged = delegate { };

in the manager create a method that you can call

public void ChangeDay()
{
    OnDayChanged();
}

In all the objects that you want to update his Age you can just subscribe to the method like this

YourScriptName.OnDayChanged += UpdateAge;

and create the method that updates the age

public void UpdateAge()
{
    age++;
}

@xxmariofer thanks for your answer :slight_smile:
I actually never used events before.
Where am I actually supposed to put the following line?

YourScriptName.onDayChanged += UpdateAge ();

I have a script where I keep the age of my characters, it should be in here?

I tried to find out by the documentation but I don’t even know what I am looking for xDD

Anyway, thanks a lot for your time