Forum rules - please read before posting.

Running a cutscene based on the player’s actual local date


I am creating a game for mobile and wonder if there is a simple way to get the player‘s local calendar date whenever he launches the game app, write it to a global var and then run a cutscene depending on its value — just like in an online Christmas calendar that has only one specific door activated every day.

Thank you.


  • edited September 2020

    Getting the current time/date involves accessing System.DateTime.Now and choosing an appropriate format. You can then update an AC Global String variable with the returned value.

    For example:

    public void DayToVariable ()
        string day = System.DateTime.Now.ToString("MM/dd");
        AC.GVar dateVar = AC.GlobalVariables.GetVariable ("Date");
        dateVar.TextValue = day;

    Calling that function will update a String variable named "Date" of the form MM/dd, so e.g. "12/25" would be Christmas Day.

  • Cool, Chris — thank you!

  • A typo in the code snippet - fixed.

  • There is one more thing, though — obviously, there is a before and an after to that calendar timespan, meaning I would have to make a mathematical comparison to the acquired current date: if before 12/01, run this cutscene, if after 12/25, run that cutscene (and of course I would have to capture the year as well, like 20/12/25)

    So I guess, I should use System.DateTime.Now.ToOADate instead and save that value in an AC global float var?

  • That function returns a double, but if you're not interested in the time of day you could probably convert it to an integer.

  • edited October 2020


    I ended up grabbing the date ToString("yyyyMMdd"), successfully "TryParsed" that to an integer and saved in to an AC Global Interger variable.

    One more thing, Chris – what would be the smartest way to make sure that script gets called on every app start? Right now I have it on an empty game object in a scene which I plan to make the starting scene. Is there a better way?

  • Well, there's nothing wrong with that approach.

    An alternative would be to assign an ActionList asset in your Settings Manager that runs when the game begins - regardless of what your starting scene is. That list could then contain an Object: Call event Action that runs the function in your script (placed on a prefab).

  • Thanks, Chris!

Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Welcome to the official forum for Adventure Creator.