How do I make turrets shooting animated object?

From the Asset Store
112 High-Quality destruction sounds for videogames
  • Hi guys,

    I want to make turrets that shoot an animated object toward the enemy.

    Probably not a bullet-like object, more like a channeling of magic or life-draining in my case.

    This is what I have in mind.

    What I did was making the turrets spawn a 'lifedrain' object when it acquires a target, then

    set its width = distance between the tower and the enemy, and set its angle toward the enemy.

    When the enemy is out of range = turrets unacquire that enemy and so the 'lifedrain' is destroyed.

    Turrets is then targeting the next enemy in range.

    It seems like working fine when there is one enemy on the layout . It still spawns the 'lifedrain',

    set width and angle toward the enemy but still got a small issue when it is at the overlapped

    zone between the two turrets' ranges.

    Also when you spawn an enemy at the bottom right corner, the lower turret still spawned the 'lifedrain',

    but it wasnt destroyed when the enemy left the range.

    Main problems appear when there were more than one enemies on the layour,

    the turrets spawn multiple lifedrains, some of those would target the out-of-range enemies,

    the extra lifedrain were not destroyed or so.

    I might not have the right approach it right as I'm still on the learning process (and I love Construct 2, so far).

    I has been stuck on this for a while so now I need some experts' touch here.

  • Edit: see edit below:

    I think I see the problem, the tower is storing the UID of the target, but when a new target appears the first UID is overwritten with the next one, so that lifedrain can no longer be found to destroy.

    Instead of storing the UID of the lifedrain in the tower, store the host tower UID in each spawned lifedrain.

    When the tower doesn't have a target, (use "for each" tower) search for any lifedrains with that tower's UID and destroy them.

    ---edit---

    Ok, it sounded logical, but I tried it, and that only helps if you are supposed to have multiple targets. ("for each" was the only thing right)

    In this case, it better to confirm the tower isn't already firing, and you won't have a conflict.

    [attachment=0:1wumzh7j][/attachment:1wumzh7j]

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Thank you, it works flawlessly now.

  • Please set topic as "SOLVED"

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