Assign an object to an enemy?

Get help using Construct 2

Post » Tue Feb 09, 2016 11:23 pm

Hey there,

I have a special problem.
In my game you can poison an enemy. Now if the enemy is poisoned, an event is creating a small symbol over the enemy with a fade behaviour. At the same time the enemy gets poisoned, set to "poisoned"-boolean and the enemies "poison_timer" starts counting down. The fade-wait is getting set to the poison timer and the fade starts. So far so good, now when the poison-timer reaches zero, the poison is gone and also the symbol has faded out. Works fine.

Now the problem is, i cant get my head around how i can make the symbol fade, when the enemy is dying.

Lets say the enemy just got poisoned, the symbol appears over the enemy and now the counter is counting down, lets say 8 seconds.
The enemy gets killed after 2 seconds. Now the enemy is dead but the symbol remains there for 6 seconds, even when dead.
Is there a way to assign the symbol to the enemy which got poisoned so it "recognizes" the enemies death. I tried setting the fade on enemys death, but that didnt work.

Hope somebody understands my problem and can help me. Thanks!
B
11
S
3
G
2
Posts: 76
Reputation: 1,891

Post » Wed Feb 10, 2016 7:48 am

Anyone knows a simple solution to this?
B
11
S
3
G
2
Posts: 76
Reputation: 1,891

Post » Wed Feb 10, 2016 7:54 am

No idea what your events look like, but I'm assuming that somehow, somewhere you're keeping the poison symbol ''alive'' until the timer runs out, so when you try and set it to fade out prior to that it just sets it back to normal.

It's hard to tell exactly what is going on without being able to look through the logic though.
B
5
Posts: 43
Reputation: 311

Post » Wed Feb 10, 2016 12:30 pm

Actually, all i wanna do is, assign an object to the enemy, so if the enemy dies, the object will disappear too. I dont wanna use containers, cause obviously you can only assign one object to one enemy.
B
11
S
3
G
2
Posts: 76
Reputation: 1,891

Post » Wed Feb 10, 2016 1:11 pm

Containers can actually contain more than two objects. :)

In the object properties:
Image

You can keep adding more objects to the container. If that solves your problem, then that's a fairly easy fix. :)
B
5
Posts: 43
Reputation: 311

Post » Wed Feb 10, 2016 1:39 pm

I meant you can only assign object A to object1 but not to object2 at the same time, thats what i meant : )
B
11
S
3
G
2
Posts: 76
Reputation: 1,891

Post » Wed Feb 10, 2016 1:46 pm

Ah, yes this is true. I guess you could create clones of existing items. Although that would mean more events to deal with the doubled objects.. So I guess a container is out of the question.

Perhaps you could say.. Store the UID of the object your poison marks are pinned to in an instance variable, and should this UID no longer exist (ie be destroyed) destroy the mark? It's a little more manual work, but it would solve your issue and make it usable on any other object.

Just thinking out loud here.
B
5
Posts: 43
Reputation: 311

Post » Wed Feb 10, 2016 2:52 pm

Hi,
the icon needs a variable "belong to"

On create set "belong to" to the enemys UID.

The Enemy on destroyed:-> poison icon with" belong to" =enemy.uid ---> poison icon destroy.

Its kinda like what Gumball said.
B
7
S
2
Posts: 56
Reputation: 583

Post » Wed Feb 10, 2016 3:19 pm

Ok thank you guys :)
@dsminor Thats what i actually thought of first, but also i thought maybe there is more "easy" and obvious way. Thank both of you!
B
11
S
3
G
2
Posts: 76
Reputation: 1,891


Return to How do I....?

Who is online

Users browsing this forum: No registered users and 4 guests