Turret - Line of Sight

Get help using Construct 2

Post » Mon Jun 10, 2013 8:02 pm

Hello Gamers,

Question, How can I make my turret behaviors only acquire a new target if the target is in line of sight. For example I have two targets same distance from the turret. One is in sight and one is behind a solid. The Turret should not acquire the one behind a solid but it should acquire the one that's in line of sight. How can I accomplish this?

Thank you,
B
8
S
1
Posts: 49
Reputation: 1,756

Post » Mon Jul 28, 2014 5:06 am

I have the same problem. Turret is trying to shoot to nearest target despite it is behind the wall. Maybe Scirra developers should add obstacles to behaviors of turret?
B
9
Posts: 16
Reputation: 457

Post » Mon Jul 28, 2014 7:02 am

Just add 'line of sight' behaviour as well as Turret.
B
24
S
9
G
4
Posts: 1,646
Reputation: 6,596

Post » Mon Jul 28, 2014 7:18 am

codah wrote:Just add 'line of sight' behaviour as well as Turret.

If turret see in line of sight several targets, and one of them is hiding behind the wall and is nearest to the turret, turret will still shoot at it. It will be good if turret in that case just switch to another target.
B
9
Posts: 16
Reputation: 457

Post » Mon Jul 28, 2014 11:29 am

I did something similar once. When my Turret acquired a target, I would check if there was also line-of-sight.. if yes, then I would fire a bullet using 'spawn sprite', not 'Turret:On Shoot'. I'm sure I had a reason for doing it that way.. but maybe you could just put a line-of-sight check in the On Shoot event.
B
24
S
9
G
4
Posts: 1,646
Reputation: 6,596

Post » Mon Jul 28, 2014 12:43 pm

codah wrote:I did something similar once. When my Turret acquired a target, I would check if there was also line-of-sight.. if yes, then I would fire a bullet using 'spawn sprite', not 'Turret:On Shoot'. I'm sure I had a reason for doing it that way.. but maybe you could just put a line-of-sight check in the On Shoot event.

Thank you a lot, i will try both ways :)
B
9
Posts: 16
Reputation: 457

Post » Mon Jul 28, 2014 5:53 pm

Here is capx: https://www.dropbox.com/s/8xa3g6gtc1cr3 ... emies.capx
I do not have any idea how to make this workable )
B
9
Posts: 16
Reputation: 457

Post » Mon Jul 28, 2014 7:08 pm

Your best bet is to use manual target acquisition. Here's your capx modified so your turret acquires the closest target in its line of sight.
You do not have the required permissions to view the files attached to this post.
B
60
S
24
G
23
Posts: 934
Reputation: 17,528

Post » Tue Jul 29, 2014 5:02 pm

Magistross wrote:Your best bet is to use manual target acquisition. Here's your capx modified so your turret acquires the closest target in its line of sight.

You are genius! :shock:
B
9
Posts: 16
Reputation: 457

Post » Tue Jan 12, 2016 5:09 pm

it is good :D
turrent can't shoot player behind wall

here's the file
tusfiles.net/1xxk3e567cwc
B
3
S
1
Posts: 3
Reputation: 281

Next

Return to How do I....?

Who is online

Users browsing this forum: ilyaTyl and 10 guests