# Arrow pointing towards a boss

Get help using Construct 2

### » Thu Sep 20, 2012 5:32 am

For some reason this is giving me a lot more trouble than it probably should.

What I want is simple, I want an arrow on the HUD that points in the direction of a boss, or the nearest boss if there are two.

I took the same condition used for my auto-turret which picks the closest instance of the "Boss" family (all bosses are members of this family, naturally), and then for the event itself I had it "rotate 50 degrees towards boss.x and boss.y" each tick.

However, nothing of the sort happens whatsoever. Instead, the arrow points south-east every time and that is where it pretty much stays (it normally has the straight east default position like most graphics).

Any tips on how to make the arrow spin and point towards the nearest boss at any given time would be greatly appreciated. Thanks!
B
19
S
6
G
5
Posts: 98
Reputation: 4,489

### » Thu Sep 20, 2012 11:28 am

perhaps try:

set angle to: angle(self.x,self.y,boss.x,boss.y) ?
B
92
S
31
G
24
Posts: 3,191
Reputation: 32,739

### » Thu Sep 20, 2012 4:50 pm

Thanks for the suggestion, but it ended up with the same result as the previous attempts.

Here is a picture of what happens:

The arrow pretty much just keeps facing that direction regardless of where the boss is (it does wobble, as if it is tracking something, but not much).

Here's what the event looks like:

Even just setting the angle to bosses.x,bosses.y results in the same issue. Thanks again for any further tips!
B
19
S
6
G
5
Posts: 98
Reputation: 4,489

### » Thu Sep 20, 2012 7:23 pm

If the arrow is on the HUD layer with 0,0 parallax then you'll have to convert the boss x,y coordinates to their HUD layer equivalents.

[code]
bossX = ViewportLeft("HUD") - ViewportLeft("Main") + Boss.X
bossY = ViewportTop("HUD") - ViewportTop("Main") + Boss.Y

Arrow: Set angle toward(bossX, bossY)
[/code]
B
55
S
29
G
19
Posts: 1,520
Reputation: 25,860

### » Thu Sep 20, 2012 9:00 pm

Sorry, forgot that. You can do as ramones said, or set the angle to
angle(player.x,player.y,boss.x,boss.y).
B
92
S
31
G
24
Posts: 3,191
Reputation: 32,739

### » Thu Sep 20, 2012 9:38 pm

Thanks a lot, it works just fine now.

Perhaps you might be so kind and share as to why the player.x,player.y works in conjunction with the boss.x,boss.y? I am not terribly up to speed on how that works. Is it calculating the angle between the player and the boss and setting the arrow to that particular angle?
B
19
S
6
G
5
Posts: 98
Reputation: 4,489