Arrow pointing towards a boss

0 favourites
  • 6 posts
From the Asset Store
Game with complete Source-Code (Construct 3 / .c3p) + HTML5 Exported.
  • 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!

  • perhaps try:

    set angle to: angle(self.x,self.y,boss.x,boss.y) ?

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

    Here is a picture of what happens:

    <img src="http://imageshack.us/a/img827/7998/blarg1.png" border="0" />

    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:

    <img src="http://imageshack.us/a/img543/3772/blarg2.png" border="0" />

    Even just setting the angle to bosses.x,bosses.y results in the same issue. Thanks again for any further tips!

  • 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.

    bossX = ViewportLeft("HUD") - ViewportLeft("Main") + Boss.X
    bossY = ViewportTop("HUD") - ViewportTop("Main") + Boss.Y
    
    Arrow: Set angle toward(bossX, bossY)
    
  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Sorry, forgot that. You can do as ramones said, or set the angle to

    angle(player.x,player.y,boss.x,boss.y).

  • 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?

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