# How do I Find an Angle Relative to Two Objects?

Get help using Construct 2

### » Sat Sep 20, 2014 11:08 pm

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
B
25
S
7
Posts: 79
Reputation: 2,267

### » Sat Sep 20, 2014 11:43 pm

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 do not have the required permissions to view the files attached to this post.
Last edited by eli0s on Sun Sep 21, 2014 12:44 am, edited 1 time in total.
composer - multimedia artist
www.eli0s.com/en/
B
69
S
27
G
6
Posts: 1,146
Reputation: 10,379

### » Sun Sep 21, 2014 12:14 am

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.

B
25
S
7
Posts: 79
Reputation: 2,267

### » Sun Sep 21, 2014 12:42 am

I hope you get well soon! Keep it up!
composer - multimedia artist
www.eli0s.com/en/
B
69
S
27
G
6
Posts: 1,146
Reputation: 10,379