How do I prioritize targets

Get help using Construct 2

Post » Fri Sep 25, 2015 1:59 am

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!

Thanks!
Last edited by artbava on Fri Sep 25, 2015 10:24 am, edited 1 time in total.
B
14
S
5
Posts: 110
Reputation: 1,338

Post » Fri Sep 25, 2015 6:47 am

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!
B
70
S
24
G
19
Posts: 1,757
Reputation: 17,614

Post » Fri Sep 25, 2015 10:59 am

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?
B
14
S
5
Posts: 110
Reputation: 1,338

Post » Fri Sep 25, 2015 5:41 pm

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.
B
44
S
11
G
2
Posts: 1,182
Reputation: 6,828


Return to How do I....?

Who is online

Users browsing this forum: 99Instances2Go, Casimir, R0J0hound, Syazanie Amirin, tarek2 and 9 guests