Assign an object to an enemy?

0 favourites
  • 9 posts
From the Asset Store
Hand-painted tiles, objects, animated objects, and background to build a colorful Mayan civilization environment.
  • 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!

  • Anyone knows a simple solution to this?

  • 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.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • 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.

  • Containers can actually contain more than two objects.

    In the object properties:

    You can keep adding more objects to the container. If that solves your problem, then that's a fairly easy fix.

  • I meant you can only assign object A to object1 but not to object2 at the same time, thats what i meant : )

  • 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.

  • 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.

  • 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!

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