How do I make turrets shoot only targets in front of it

Get help using Construct 2

Post » Tue Mar 25, 2014 10:26 am

Hi, please look at attached capx. Its just an example of tower defence that I found here on the forum. I made some changes to it.

The problem is that the turrets with a long range and rotation will target the nearest or first in range targets which is not good for my game. I want to make turrets shoot only targets in front of it but not from the other spawner or line. Ofc, I can disable rotation but It will limit tower places.

Also, I found interesting thing during experimentations. If disable rotation and place turrets only in front of the spawners they will shoot their targets by targets positioning (both for nearest and first in range options). If the targets is on the same distance to the towers they will shot simultaneously. But if the front target is farther than the target of the upper or lower turret it won't shoot till the closest target will be destroyed. It is clearly seen if you place 1 tower in front of each spawner and play till wave 2 or 3.

I just want make turrets from each line shoot targets from their own spawner. Is that possible rather than making enemy clones for each spawner and checking where turrets were placed and programming them to shoot targets from their line? Huh. Thanks.
You do not have the required permissions to view the files attached to this post.
B
3
Posts: 4
Reputation: 183

Post » Tue Mar 25, 2014 10:49 pm

Click on ArrowTurret, and change the following properties

Rotate - Yes
Target Mode - Nearest
Using R243 for all examples
B
69
S
20
G
6
Posts: 379
Reputation: 9,699

Post » Wed Mar 26, 2014 1:38 am

emoaeden wrote:Click on ArrowTurret, and change the following properties

Rotate - Yes
Target Mode - Nearest


If I do so, then turrets will shoot at targets from other lines which is not acceptable for me.
B
3
Posts: 4
Reputation: 183

Post » Wed Mar 26, 2014 2:32 am

You could give each target a Variable, and have turrets that are in the middle, shoot only targets that have the variable Middle.
Using R243 for all examples
B
69
S
20
G
6
Posts: 379
Reputation: 9,699

Post » Thu Mar 27, 2014 10:44 am

emoaeden wrote:You could give each target a Variable, and have turrets that are in the middle, shoot only targets that have the variable Middle.

Sounds great, but in practice I've got troubles.
I can give variables to targets, but how make turrets target only enemies with that variable?
B
3
Posts: 4
Reputation: 183

Post » Thu Mar 27, 2014 12:23 pm

Code's a bit longer, and goes down a few levels, but it does the job. Reason it's set out this way, is because if you move the action of line 31 to line 29, it freaks out, because it doesn't know which Enemy to target when they are the same distance from the ArrowTower.

I also removed a few unnecessary lines of code, and a few duplicate sprites, and am now using instance (very handy :) )

https://dl.dropboxusercontent.com/u/108 ... iming.capx
Using R243 for all examples
B
69
S
20
G
6
Posts: 379
Reputation: 9,699

Post » Thu Mar 27, 2014 7:46 pm

Message: drizzlle is not yet permitted to post plain text URLS (300 rep required). 1 URLS removed. Why?
emoaeden wrote:Code's a bit longer, and goes down a few levels, but it does the job. Reason it's set out this way, is because if you move the action of line 31 to line 29, it freaks out, because it doesn't know which Enemy to target when they are the same distance from the ArrowTower.

I also removed a few unnecessary lines of code, and a few duplicate sprites, and am now using instance (very handy :) )

Wow, thanks!
B
3
Posts: 4
Reputation: 183


Return to How do I....?

Who is online

Users browsing this forum: lukewasthefish and 14 guests