...create TowerDefense (aim Enemys)?

Get help using Construct 2

Post » Tue Jan 29, 2013 8:45 am

Hello and sorry about my english!

I try to make an TowerDefense Game - yes, i know it's hard and Pong would be easier *hehe*

I make a lot of things for these game what works fine for me (buying diffent types of towers, upgrading towers, sell towers, path-finding for enemys,...), but there's one thing i'm not able to accomplish:

AIM ENEMYS!

HERE you can see a test (HTML5) and HERE you can download the .capx file
(includes only the most necessary objects)

My problem/question: why does the tower loose the target to the enemy he already shot, BEFORE the distance is more then (in this example) 128px?

I already tried out the turrets-addon, but i also don't get fixed it... :(

Thanks very much!
B
20
S
5
G
2
Posts: 175
Reputation: 3,462

Post » Tue Jan 29, 2013 9:18 am

You are always targeting the closest enemy with 'pick nearest to tower' event.

If you wish to change it to something else you could do it like this:

Tower defense demo

Not the most elegant way, but you'll get the idea :)
B
24
S
8
G
7
Posts: 756
Reputation: 7,202

Post » Tue Jan 29, 2013 1:11 pm

Thanks - works fine!
But is it possible, that it also works with "familys", so i don't have to create a lot of events for each kind of tower and enemy?
B
20
S
5
G
2
Posts: 175
Reputation: 3,462

Post » Tue Jan 29, 2013 1:21 pm

[QUOTE=Cherico] Thanks - works fine!
But is it possible, that it also works with "familys", so i don't have to create a lot of events for each kind of tower and enemy?
[/QUOTE]

Sure, just replace the 'tower01' or 'enemy' parts with corresponding family and it should work just fine.
B
24
S
8
G
7
Posts: 756
Reputation: 7,202

Post » Tue Jan 29, 2013 1:37 pm

And whats with the instance variables? Have i also change it to family-variables?
B
20
S
5
G
2
Posts: 175
Reputation: 3,462

Post » Tue Jan 29, 2013 1:40 pm

[QUOTE=Cherico] And whats with the instance variables? Have i also change it to family-variables?[/QUOTE]

Yup, otherwise you cannot access them when referencing an object through family.
B
24
S
8
G
7
Posts: 756
Reputation: 7,202

Post » Tue Jan 29, 2013 2:37 pm

Ok, i get it - thank you very very very much!!!
The community and the people here are so great!!!

But now i have another problem :(

The distance is (in our case) 128px - but how do i realize it when i have diffent towers with different ranges?
So tower1 have 128px, tower2 196px, tower3 256px,...
And when i upgrade an tower his range also increases...
B
20
S
5
G
2
Posts: 175
Reputation: 3,462

Post » Tue Jan 29, 2013 6:01 pm

[QUOTE=Cherico] Ok, i get it - thank you very very very much!!!
The community and the people here are so great!!!

But now i have another problem :(

The distance is (in our case) 128px - but how do i realize it when i have diffent towers with different ranges?
So tower1 have 128px, tower2 196px, tower3 256px,...
And when i upgrade an tower his range also increases...[/QUOTE]

Create another family variable, range, in your tower family so all your tower types will have it. Now you can define the range for every tower type individually. You can refer to it via familyName.range in the events (range check in this case)
B
24
S
8
G
7
Posts: 756
Reputation: 7,202

Post » Wed Jan 30, 2013 3:53 pm

It works absolutly great - very very very big thanks!

But i have another problem...
(sorry)

When i build a tower near at the end of the road and an enemy reaches the end (out of screen - there he will be destroyed), the tower does not react anymore... As the thought "Hu... Where is he?!"
B
20
S
5
G
2
Posts: 175
Reputation: 3,462

Post » Wed Jan 30, 2013 4:05 pm

Edit: i get it ;)
B
20
S
5
G
2
Posts: 175
Reputation: 3,462

Next

Return to How do I....?

Who is online

Users browsing this forum: 99Instances2Go, Artpunk, Google [Bot], Magistross and 31 guests