How do I Make this trigger only once?

0 favourites
  • 5 posts
From the Asset Store
Change the size and position of everything without calculating anything!
  • I'm trying to make it so that:

    If Fireball collides with Enemy - reduce Enemy health by 10

    If the Enemy stops touching the Fireball, and then touches it again, I do NOT want the damage to happen again.

    The only thing I can think of is to add a variable to the Enemy that becomes the UID of the Fireball when they collide, and then preventing damage from happening if the variable is the same as the UID.

    However this would be inconvenient because I plan on having a large number of these types of abilities, and I don't want to make a new variable for each one.

    I feel like I'm missing something simple but I can't figure it out.

    ::EDIT:: I forgot to mention that I need this to work if it overlaps multiple enemies at the same time. I tried to store the enemy UIDs in a List but the list won't accept them. Is there a way to store multiple UIDs in a list and then reference them somehow?

    Thanks for any input

  • You could do as you say only either use the dictionary object or an array so in a sense your creating the variable dynamically, or have your variable as a string and store the uid as a token and check all the token uids on the next overlap.

  • Hey thanks for the response. I've never really used any of these functions before and am looking them up trying to figure it out.

  • This seems a bit simple and might work for you but did you try combining trigger once and destroying the projectile if it hits even one enemy?

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • This seems a bit simple and might work for you but did you try combining trigger once and destroying the projectile if it hits even one enemy?

    Hey Destitute, thanks for the response.

    I should have mentioned that the "Fireball" object is supposed to be like an explosion, that stays on the screen for a few seconds, and damages any enemies that touch it.

    I think I've found a solution.

    What I've done is every time a "Fireball" is created, I create an Array with an "ID" variable that is set to that Fireball's UID.

    Then if an enemy touches it, it deals damage then adds the enemy's UID to it's array and won't damage it again if that UID is on it's array.

    Then when the fireball is destroyed, so is it's array.

    So far it seems to be working and I haven't found anything wrong with it.

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