# How do I set angle towards mouse position?

Get help using Construct 2

### » Wed Jul 13, 2016 11:54 pm

Hello, comunity :3

I'm making a sort of an "Asteroids" game, but I'm trying to set the ship angle based on the mouse position, not by the arrow keys.

I'm using this - Every Tick: Sprite > Set angle toward (Mouse.X, Mouse.Y)

It's not working, since the nose of the ship does not follow the mouse, just the anchor point of the sprite, which makes it spin in the mouse direction, but not in the way that I want it to.

Can anyone help me, pls? Thank You
Riding the Rainbow for all the eternity
B
10
S
5
Posts: 31
Reputation: 934

### » Wed Jul 13, 2016 11:59 pm

Try Set angle TO angle(sprite.x,sprite.y,mouse.x,mouse.y)
B
62
S
30
G
134
Posts: 1,976
Reputation: 75,479

### » Thu Jul 14, 2016 1:43 am

oosyrag wrote:Try Set angle TO angle(sprite.x,sprite.y,mouse.x,mouse.y)

Sorry, I didn't get it.
B
10
S
5
Posts: 31
Reputation: 934

### » Thu Jul 14, 2016 3:34 am

angle() is an expression that gives you the angle between two points, in this case from the sprite to your mouse.

So every tick, set angle to angle(sprite.x,sprite.y,mouse.x,mouse.y)
B
62
S
30
G
134
Posts: 1,976
Reputation: 75,479

### » Thu Jul 14, 2016 3:58 am

oosyrag wrote:angle() is an expression that gives you the angle between two points, in this case from the sprite to your mouse.

So every tick, set angle to angle(sprite.x,sprite.y,mouse.x,mouse.y)

Welp, it didn't worked at all. It worked, but had the same issue that I was facing using the other way: it's not facing the right direction, the mouse is always tangentially to the ship. I took a print to show where the mouse was.

Riding the Rainbow for all the eternity
B
10
S
5
Posts: 31
Reputation: 934

### » Thu Jul 14, 2016 5:23 am

In the sprite editor, the right side is 0 degrees, or "forward", not the top.
B
62
S
30
G
134
Posts: 1,976
Reputation: 75,479

### » Thu Jul 14, 2016 7:41 am

So, or rotate the sprite in the image editor 90 degrees clock wards. And account for that in your other events.

Or, set its angle to angle(sprite.X,Sprite.Y,mouse.X,mouse.Y) + 90 ... (every tick)
B
33
S
18
G
29
Posts: 2,493
Reputation: 21,450

### » Thu Jul 14, 2016 3:15 pm

It worked! Thanku, guys ^^
Riding the Rainbow for all the eternity
B
10
S
5
Posts: 31
Reputation: 934