Forum rules - please read before posting.

Game Timer and Calling Cutscene

edited April 2014 in Technical Q&A
Firstly, thanks for Adventure Creator!  It's amazing!

I'm busy creating a 2D game and instead of using various scenes I have all the backgrounds in one scene and I switch from camera to camera as the character moves between them.

The game is time based and actions happen in real time. So for instance a dialogue can start between two NPCs at a certain time even if the camera is not currently focused on them.  The game will also show a countdown timer that starts at 5 minutes for instance and when it hits 0 the game is over.

I thought about how to do this in Adventure Creator and the best I can think of is this:
1. Create the countdown timer in code and update the GUI with the values.
2. When it goes over a certain time run a cutscene. (set var to true so that it only happens once)
3. Pause the timer by setting a boolean when the game is paused (for instance when in menu)

Is this the best way to accomplish a time based game?

And the big question: How would I call a cutscene to run from code?

Also is there a variable that's set already when the game is paused so that I can just look at that in code to pause the timer?

Thank you for your time. :)

Comments

  • When the game is paused, the gameState enum in the StateHandler script is set to Paused:

    if (GameObject.FindWithTag (Tags.persistentEngine).GetComponent <StateHandler>().gameState == GameState.Paused)
    {
      // Do something
    }


    To call a Cutscene from code, simply run it's Interact function.

    However, you may want to use Global Variables for this.  You can display the value of an AC Variable in a MenuLabel by inserting [var:2] into the label text box, where 2 is the variable ID number (shown to the left of each variable in the Variables Manager).

    You may also prefer to hold out for the upcoming 1.30 update, which amongst other things, introduces float variables, and the ability to set variables with forumlas (e.g. 2*3 + 4-[var:2]) in the Variable: Set Action.  Combined with Pausing Actions in a Cutscene that's set to run "In Background" (so that pauses actually become delays), you may be able to script this entirely through Cutscenes.
  • Excellent, thanks for the comprehensive answer Chris!  I'll work on other parts of the game so long and then wait for 1.30 to do it via Cutscenes.
  • "To call a Cutscene from code, simply run it's Interact function" care to elaborate? @ChrisIceBox
  • @Antonis:

    Say you have a public Cutscene variable called myCutscene in your script.  This line will initiate it:

    myCutscene.Interact ();

    You can also do this with the Object: Send message Action, by selecting the Cutscene and setting the "Message to send" to "Interact".
  • @ChrisIceBox thanks man you are great as always
  • Thanks Chris, this saved me too :D
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.