Line of sight that is just on one axis

0 favourites
  • 3 posts
From the Asset Store
solution for games like "fruit ninja" and drawing applications
  • 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.

  • I made something. Maybe is what you looking for:

    drive.google.com/file/d/0B5FlDY8sggF4b2x5N3g3ZEZjTDA/view?usp=sharing

    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'

  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • Thanks Asmodean going to check it out.

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)