Forum rules - please read before posting.

On screen timer

edited August 2017 in Technical Q&A
Hello,

I would like to time some parts of the game, for example when a player enters the trigger he'll have a minute to do a short QTE and pick up two objects in different places, or he'll lose. I'm doing this with a variable that adds 1 to itself every second, and while it works, I weren't able to find a way to show the remaining time. It wold be perfect to have a slider connected to the variable to display the changes. Can this be done without any custom scripts? Or perhaps there is a better way to do this?

Thanks!

Comments

  • If you don't want to do any coding or use a second variable to keep the Remaining time, I'd recommend you to use a countdown instead. Set the var to the max time (say 30), then remove -1 every second. this way you can create a UI label (in the AC menu manager), and tie it to that variable (tying a gVar to a UI Label only works for global variables). Else, you can just use any label and use a token to show the variables value, by using [var:ID] or [localvar:ID] (where ID is the number id of the variable, which you can see in the variables info in the Variables Manager).
  • Welcome to the forum, @skanablu.

    If the Variable's type is Float, you can have its value displayed in a Slider Menu.  This works for Unity UI-based Sliders, too, for a bit more visual control over it.
  • Thank you for your help! It's almost working now, but I still got 2 problems:

    1. If I'll use AC slider, it seems that I can't use tokens as a label to show the remaining time (it will literally display [var:xx]). I had to make an another label menu element to display the variable and manually place it over the slider.
    2. If I'll use the Unity UI slider, then it doesn't seem to work at all. My slider will appear when it should, but it's value won't change despite the fact that it's set to show the var.
  • 1. Very well, I'll allow tokens to work with AC Sliders.

    2. Is your UI Slider correctly linked to the Slider Menu Element?  You must ensure that the Slider component shares the same Constant ID number that is listed in the AC Slider properties.  Please post images showing what you've done so that we can examine the issue.
  • edited March 2023

    Hello. I'm looking for a method of putting a timer on the screen so that when the time runs out it's the end of the game, and that time can be added or decreased as an item is picked up. Using AC. I don't understand variables well.

    How do I do it?

  • Since this thread was posted, AC has a dedicated Timer feature. You can create a Timer from the top toolbar, under Adventure Creator -> Editors -> Timers Editor.

    Create a new Timer, and check Link to Global Variable?. Create a Global Integer variable, setting its Default value to the default length of time (in seconds) and link it to the Timer.

    Set the Timer's Value increases per tic property to -1, and set the Max value to the highest amount of time you want the timer to be.

    At runtime, you can then use the Variable: Set timer Action to begin the Timer, which will reduce the Integer variable's value by 1 every second.

    To have the game end when it reaches zero, assign an ActionList asset in the Timer's ActionList on update property. Set this list's When running property to Run In Background, and have it run a Variable: Check Action to check if the Integer variable's value is zero. If it is, have it run the Engine: End game Action to end or restart the game.

  • The Timer is not working, I created a menu to show the time on the screen.

  • You need to call the Variable: Timer Action separately - it shouldn't be part of the "On Update" ActionList, but run when the scene / game begins.

    You can also remove the "On Update" ActionList - and instead use the "ActionList on complete" field to run your Engine: End game Action.

  • It worked out. Thanks

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.