I use the Timer Behavior as a 'in-object function'.

0 favourites
  • 8 posts
From the Asset Store
This is a single chapter from the "Construct Starter Kit Collection". It is the Student Workbook for its Workshop.
  • I basically use the Timer for actions that I want to be preformed consistently. Like for example I will have a timer for "Damage Taken" so that whenever the object takes damage, it will react in a consistent way. No matter how it takes damage.

    I was just wondering if there was a better way to do this. Like maybe I could use variables. (e.i. Set "Damage Taken" to true) Or maybe I should try something completely different. I just want the least CPU intensive way possible.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Why not use a regular function to the same effect? Am I understanding this incorrectly?

    [Object takes damage] --> run function "Damage Taken"

    [Function "Damage Taken] --> play animation, subtract health, build more pylons, etc.

  • Sup with that? The problem with using normal functions, is that you cannot use it with multiple objects. Say you have a bunch of enemys, and you attack one. If you use normal functions, every single enemy takes damage.

  • You pass in the UID of the enemy as a parameter, then Pick by UID first. Then it only affects the one enemy.

  • The problem with the timer is that if your object takes damage again before the end of the first timer (unless you use a timer of 0?), the timer will only reset and the effect will not be applied.

    blackhornet solution feels more natural to me, but I believe you could also use timers of 0 seconds for that.

    If I'm correct though, functions are triggered immediately, while a "on timer" will not trigger before the end of the current tick (for a 0 second timer), so the function is probably superior.

  • Sup with that? The problem with using normal functions, is that you cannot use it with multiple objects. Say you have a bunch of enemys, and you attack one. If you use normal functions, every single enemy takes damage.

    You can, you just need to use pick by uid in subevents of the function. Here's an example where I pass the attacker's uid and the defenders uid in separate parameters of the function (my function object is called f):

    http://imgur.com/a/qSRqc

    Of course if I need something from the attacker (a variable value) in a sub-event where the defender is picked I use pick all to reset picks and pick by UID attacker again. Although I prefer to just store everything I need in variables local to the function.

  • Rable I do actually set the time to 0. But I think I am going to start using functions, now.

  • Rable I do actually set the time to 0. But I think I am going to start using functions, now.

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