How do I change the length of a timer with a variable?

0 favourites
  • 7 posts
From the Asset Store
Easily store, modify, read and manipulate colors with Color Variables!
  • I'm trying to change the length of a timer but can't figure out how.

    I start the timer on start of layout and while moving I resume timer and while not moving I pause it.

    I have the duration set to a variable (which is 1) but if I change the variable, the timer duration doesn't change with it.

    Is there any way to actually do this?

  • I don't think you can change the duration of an already running/paused timer. If you stopped it instead, you could restart it with a new duration.

  • Well that's annoying. I don't think there is any way to do what I wanna do then.

    I tried using the Wait X Seconds action, but it's kind of inconsistent for some reason.

    Like if I have it subtract 1 from a value every 1 second but only if I'm moving, it doesn't work properly. Because even if I only move for 0.1 seconds and then don't move for the rest of the second, the next time I move it will still subtract 1 without moving for a full second overall.

  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • Wasn't sure what exactly you wanted so here are two different solutions

    https://drive.google.com/file/d/19bya5YNtoExw7D3T8KDGZXnlV8etefr9/view?usp=sharing

  • One of the solutions almost did was I was looking for.

    I'll try to be more specific.

    I have a variable "FuelEfficiency" = 1

    And a variable "Fuel" = 50

    I want to subtract 1 "Fuel" every "FuelEfficiency" seconds while moving is true.

    So if I change "FuelEfficiency" to 3, then I would want 1 "Fuel" to be subtracted every 3 seconds that I move.

    The problem I am having is that if I use the "Every X Seconds" action to do this it works, But once I start moving, it counts the 3 seconds even after I stop moving. So the next time that I move it will still subtract 1 from "Fuel" even though I've only moved a total of 1 second.

  • would be the same as the first solution, but instead of just subtracting dt subtract dt/fuelEfficiency every tick the car is moving.

    (I updated the project and added fuelEfficiency, same link)

  • Wasn't able to open it because it was made on a newer version of construct.

    But I made the changes in my project and it seems like that worked, thanks!

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)