How do I prioritize targets

0 favourites
  • 4 posts
  • I have several targets named as Target1, Target2, Target3, ..., Target8 (these targets are static) however enemy's position changes on every shot, randomly. I would like to calculate the angle between the enemy and the targets to determine which one can be shot at without hitting the obstacles. However depending on the enemy's position, which is random, I wish he could choose priority targets. Targets have priority within each other, i.e., Target1 have priority over Target2 which has priority over the target3 and so on.

    I'm not using LOS cause even if the enemy has line of site of the target, sometimes the bullet could not pass between the obstacles, hitting them most of the times. (His bullet is much larger than the LOS and there is just small gaps between some obstacles).

    My questions are:

    1) How may i set the Target priority? - (nearest/furthest isn't doing the job, cause the priority targets are not always near or far, as enemy's position changes)

    2) Is it possible to create a variable, to change selected Target ? What I imagine, but can not do, at least with my little knowledge is: angle (enemy.X, enemy.Y, Target (T) .X, Target (T) .Y)

    In this case, assuming that it is not possible for the enemy to hit the Target1 I would simply add (T + 1) to calculate the angle between the Target2, and so on.

    I know this is a lot of work, maybe too advanced for a newbie like me, but if you may have some ideas, it will be great!


  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • This is a case of using the pick instance on evaluate, then you can add an instance variable to your family of targets, then filter them out with the pick usage.

    ie. Pick All Target when Target.IsPriority=1 will only select any target which has its instance variable "IsPriority" = to 1. which you can set base on other calculations.

    Hope that helps!

  • SilverForce,

    Thanks, i've created a family with an instance variable called "IsPriority" as you suggested and defined priority values to them. Then i picked targets by lowest "Ispriority". Now, how can i set the angle to the picked objects? ie, how may I refer to these objects in a set angle event or action expression?

  • There is a rotate towards position I think its called, you can add the X,Y position of the picked object in here. Also Angle(X1,Y1,X2,Y2) will give you the angle between two objects. But sounds like the first option is what you might be looking for.

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