How do I make damage dependent on time?

0 favourites
  • 4 posts
From the Asset Store
An educational game for Times Table. An easy to use template for developers to build larger games
  • Hey I wanted to have a flashlight mechanic in my game in which the ghosts are damaged for 25 health out of 100 for every second that the flashlight beam crosses over them but it seems to be damaging them even if the beam had crossed over it for less than 4 second. If you know a method to make this damage time based that would be greatly appreciated!

    Tagged:

  • What I am assuming:-

    If flashlight shines on ghost for less than 1 second-->no damage

    If flashlight shines on ghost for 1 second-->25 health deduct

    Or If flashlight shines on ghost for 2 second -->50 health deduct

    And there are multiple ghosts in the game

    My solution:-

    1.)Make an instance variable for the ghost sprite named "ghost_death_counter"

    2.) (If "flashlight sprite" overlaps "ghost sprite") & (every 0.0 second) --> add 0.01 to ghost sprite's instance variable named "ghost_death_counter"

    3.) (For every ghost sprite) & (If value of "ghost_death_variable" >=1)--> (reduce 25 from its health) & (reset value of "ghost_death_variable" to 0)

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • If your light beam is a sprite, you can use:

    If ghost overlap light_beam

    >(Sub-event)Every X second => Subtract X from ghost.HP

  • add a timer behavior, and make it fire continuously, but when it hits a certain counter (which can be an instance variable) stop the timer?

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