How do I Find an Angle Relative to Two Objects?

0 favourites
  • 4 posts
From the Asset Store
Footsteps SFX Two contains 450 sounds of steps and jumps on different surfaces.
  • Hello All and thank you for looking

    I have 2 objects; an enemy & a hero. I want the enemy to change animations depending on the angle between the 2.....but, I cannot figure it out.

    If I use int(angle(hero.X, hero.Y, enemy.X, enemy.Y)) I can get a number but it changes as the hero moves closer or further away form the enemy (doesn't follow a set perimeter.)

    In the diagram, the dark blue circle is at ~330 degrees but the the light blue circle is not. I want C2 to return the same degree regardless of how close/far the circle is and instead just give me the angle it sits on? How do I go about setting a command that returns the angle I'm looking for?

    Thank you for looking

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • What you describe is oxymoron. On the one hand you want an angle based in the relation between the Rectangle and the Circle(s), on the other hand you want a fixed angle for the Circle even when the relations between them change. It isn't the distance that affects the angle, it's the actual change in the angles between the center of the Circles and the Rectangle. Try to visualize two lines that connect the Rectangle's center and the center of both Circles and you will see that they produce different angles with the horizontal axis in your picture. See the attached capx.

  • You're correct. I have the flu...my brain is not at optimal performance I am getting the correct angles....perhaps, my code is wonky.

    Thanks for the reply.

  • I hope you get well soon! Keep it up!

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