How do I Make this trigger only once?

Get help using Construct 2

Post » Sun Apr 23, 2017 5:54 am

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
Last edited by Maako on Sun Apr 23, 2017 10:37 pm, edited 1 time in total.
B
8
S
3
Posts: 49
Reputation: 698

Post » Sun Apr 23, 2017 10:17 am

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.
B
43
S
22
G
20
Posts: 735
Reputation: 11,977

Post » Sun Apr 23, 2017 10:22 pm

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.
B
8
S
3
Posts: 49
Reputation: 698

Post » Mon Apr 24, 2017 10:36 am

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?
Zelda Gamekit (my project)



Example capxs:

Zelda-Style Inventory

Zelda Health

3-saveslot system

[url=https://www.dropbox.com/s/d4396pwak0oh7q6/ZeldaDialogueSystem.capx?dl=0]Zelda-like Dialogue[
B
47
S
24
G
30
Posts: 517
Reputation: 19,464

Post » Wed Apr 26, 2017 8:31 pm

LaDestitute wrote: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.
B
8
S
3
Posts: 49
Reputation: 698


Return to How do I....?

Who is online

Users browsing this forum: KTML5 and 6 guests