How do I make turrets shooting animated object?

Just started using Construct 2? Post your questions here

Post » Mon Dec 15, 2014 6:25 pm

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.

Image

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.

Image

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.

Image

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.

Image

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.
You do not have the required permissions to view the files attached to this post.
B
7
S
2
G
1
Posts: 42
Reputation: 1,144

Post » Mon Dec 15, 2014 10:41 pm

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.

lifedrain_turrets.capx
You do not have the required permissions to view the files attached to this post.
B
226
S
60
G
33
Posts: 902
Reputation: 39,989

Post » Wed Dec 17, 2014 3:04 am

Thank you, it works flawlessly now.
B
7
S
2
G
1
Posts: 42
Reputation: 1,144

Post » Sat Jul 04, 2015 7:10 pm

Please set topic as "SOLVED"
B
16
S
8
G
1
Posts: 153
Reputation: 2,549


Return to Beginner's Questions

Who is online

Users browsing this forum: No registered users and 2 guests