Line of sight that is just on one axis

Get help using Construct 2

Post » Sun Sep 06, 2015 3:42 am

Hello everyone

I looked around for the answer to this but couldn't find one, maybe one of you guys can help.

So here's the dilemma. I want my enemy AI to shoot at my player when the player is directly in front of the enemy, on the X axis only and only when the player is in front not behind and keep shooting inside the range. I don't know if that makes sense.

So say the enemy firing range is 300, so it would go: if player.X<300 of enemy.X {keepshooting} and only in front of where the enemy is facing. Hope that makes sense, and I know that it seems so simple and it probably is but for the life of me I cannot put the logic together. Thanks in advance.
Posts: 2
Reputation: 204

Post » Sun Sep 06, 2015 6:12 am

I made something. Maybe is what you looking for:

There are two 'characteristics' or 'special feature' in this capx.
First I had to check a range of Y values. Normally it hat to be enough to check if Y-position of the enemy is equal to the Y-position of the player. But if the player is fast enough it will not trigger this event, because the player is faster then 1 pixel per tick and will not hit this exact value. So I had to check a range.
Second don't use mirror to turn your enemy. If you do the angle of facing will always 0° you have to use 'set angle'
Posts: 499
Reputation: 2,353

Post » Mon Sep 07, 2015 4:08 pm

Thanks Asmodean going to check it out.
Posts: 2
Reputation: 204

Return to How do I....?

Who is online

Users browsing this forum: urkokan and 9 guests