Trying to tweak attack AI

  • Here are the events I use to make the enemies attack when within range of the player. Can I be more specific between the x and the y meaning, could I have the attack happen when the enemy is within 200 pixels of x and 50 pixels of y?

    <img src="https://dl.dropboxusercontent.com/u/60595907/2.jpg" border="0" />

  • I'm not sure what are you looking for... however

    Use Instance variables for each sprite while comparing the distance.

  • What Joannesalfa said. Also, as far as I can tell, you don't need to check the distance between your enemy and the player twice, just go 'else' for the second condition.

  • The distance() function wont distinguish between different x and y target values, so don't check that way.

    instead, directly compare the x values and the y values. Since the enemies can be on either side and above or below, you could end up with either positive or negative values. so, use the ABS() function (which returns the absolute value, always positive).

    So, where you have the first sub event where you check Distance, replace that with:

    System: Compare two values: ABS(BoxWalker.X - BoxPsi.X) <= 200

    then add another condition:

    System: Compare two values: ABS(BoxWalker.Y - BoxPsi.Y) <= 50

    and, as TiAm said, then later use ELSE where you have the second Distance() function.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Great suggestions. Changed condition to else and did as you said AllanR - Thanks!

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