Turret behavior - only target if other target is there

0 favourites
  • 10 posts
From the Asset Store
Aim carefully a shoot the ball at the target to earn scores!
  • I have a rather specific issue.

    Its kinda hard to describe so i have made a small capx to try to explain.


    The "shooter" object is a bullet with turret behavior

    It can target both enemy1 and enemy2, but here is my dilemma. I only want it to target enemy1 if enemy2 is in front of the shooter, and only the closest instance of enemy2, it should ignore the other enemy2 far to the right.

    If enemy2 is not present next to enemy1 the shooter object should continue its bullet course straight forward and ignore enemy1.

    Anyone have any ideas?

  • It's hard to understand the reason of the comportment you describe.

    Thus, I'm not really sure I understand.

    But I read this as:

    if shooter has in range enemy1 and 2 enemy 2, it should first target enemy 1 if enemy 2 isn't on the back of the shooter (?), else, the closest enemy2... Still feel kind of weird.

  • Yann Sorry for the lack of clarity in my explanation. I was trying to keep it simple, but it probably got to simple.

    Enemy2 is actually a wall.

    if you run the capx you can see that the shooter will move forward until it find its first target which will be enemy1.

    The thing is that i only want the shooter to stop and shoot enemy1(the red ball) if the wall(enemy2) is up. If the wall is gone/destroyed then the shooter should continue through the gap between the 2 enemy1's.

    Hope that made it a bit more clear. otherwise let me know

  • See if you can work it out with this CAPX

  • Lordshiva1948

    Thx for the try. for me that makes the shooter jump to the location of enemy one (when i run it at least) which is not what i wanted.

    I actually solved it by using the line-of-sight behavior.

    I made an object behind the wall and if the shooter has line of sight on that object it will not attack the enemies but go between them.

  • Could you not just set a boolean (false if no wall true if wall - set at an appropriate time) and use this to decide on the attack action?

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Well in principle i could, but the walls move around, so i would then have to keep track of where the walls are and where they are not. The line-of-sight thing is more flexible.

  • CVP nice work I am glad you work it out good luck in future

  • Lordshiva1948

    Thank you. And thank you again for taking the time to look at the topic. Always nice with some input

  • CVP you welcome we are here to help. Ask anytime if we can help we will good luck

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