How do I set angle towards mouse position?

Get help using Construct 2

Post » 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 :D
Riding the Rainbow for all the eternity
B
10
S
5
Posts: 31
Reputation: 934

Post » Wed Jul 13, 2016 11:59 pm

Try Set angle TO angle(sprite.x,sprite.y,mouse.x,mouse.y)
Mistakes were made.
B
49
S
24
G
107
Posts: 1,581
Reputation: 60,303

Post » 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

Post » 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)
Mistakes were made.
B
49
S
24
G
107
Posts: 1,581
Reputation: 60,303

Post » 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.

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

Post » Thu Jul 14, 2016 5:23 am

In the sprite editor, the right side is 0 degrees, or "forward", not the top.
Mistakes were made.
B
49
S
24
G
107
Posts: 1,581
Reputation: 60,303

Post » 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
27
Posts: 2,440
Reputation: 20,344

Post » 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


Return to How do I....?

Who is online

Users browsing this forum: AekiroStudio, Linetaru and 8 guests