# How do I set angle to moving direction

Get help using Construct 2

### » Tue Sep 15, 2015 5:05 pm

hi,
i have an object wich i can drag
i want my object look at the direction i drag it
so i must get angle from moving but i dont know how !?
B
17
S
6
Posts: 245
Reputation: 1,784

### » Tue Sep 15, 2015 5:27 pm

You can compare every tick if the X and/or Y is increasing or decreasing. For the X axis example: If it's increasing, it means its going right. If it's decreasing, it means its going left. It's the same for the axis Y.
B
56
S
21
G
3
Posts: 602
Reputation: 6,612

### » Tue Sep 15, 2015 5:43 pm

kossglobal wrote:You can compare every tick if the X and/or Y is increasing or decreasing. For the X axis example: If it's increasing, it means its going right. If it's decreasing, it means its going left. It's the same for the axis Y.

so how i set the angle !?
B
17
S
6
Posts: 245
Reputation: 1,784

### » Tue Sep 15, 2015 6:05 pm

August 2015 - I misplaced a lot of links - I will try to find backups and repost. If You find a post that interests please reply to post with @rampackwobble and I will get a nudge!

If you find my posts useful please consider donating something to a local charity or to the http://www.mndassociation.org/
B
64
S
34
G
47
Posts: 1,194
Reputation: 30,902

### » Tue Sep 15, 2015 7:03 pm

mahdi71 wrote:
kossglobal wrote:You can compare every tick if the X and/or Y is increasing or decreasing. For the X axis example: If it's increasing, it means its going right. If it's decreasing, it means its going left. It's the same for the axis Y.

so how i set the angle !?

The way I explained you don't need the angle. But you also need to explain how is your game in order to know the best way to do it. It is a platform or Top-down?
B
56
S
21
G
3
Posts: 602
Reputation: 6,612

### » Tue Sep 15, 2015 7:15 pm

if your dragging ur object... or u have to touch ur finger on screen... set.angle to direction Touch.x Touch.y thats it .... or set.angle to angle(player.x,player.y,touch.x,touch.y) or ... rotate towards angle = angle(player.x,player.y,touch.x,touch.y) ... . no crazy coding needed

the player.x player.y being the object your drag
B
83
S
24
G
69
Posts: 1,368
Reputation: 44,253

### » Tue Sep 15, 2015 8:23 pm

RamPackWobble wrote:one way

https://goo.gl/CpAixD

thanks but when you drag object slowly then its not smooth and change direction so fast, it seem crazy !
B
17
S
6
Posts: 245
Reputation: 1,784

### » Tue Sep 15, 2015 10:19 pm

I told my dentist I had trouble with my teeth and asked her to fix it without looking in my mouth..
B
54
S
16
G
8
Posts: 6,160
Reputation: 19,775

### » Wed Sep 16, 2015 7:14 am

and what's wrong with crazy ?

Version 2 -

https://goo.gl/zBlaR2

known problem - If you move very slowly "backwards" with constant "left/right" corrections you can reverse the arrow straight back but apart from that....
August 2015 - I misplaced a lot of links - I will try to find backups and repost. If You find a post that interests please reply to post with @rampackwobble and I will get a nudge!

If you find my posts useful please consider donating something to a local charity or to the http://www.mndassociation.org/
B
64
S
34
G
47
Posts: 1,194
Reputation: 30,902

### » Wed Sep 16, 2015 1:03 pm

RamPackWobble wrote:and what's wrong with crazy ?

Version 2 -

https://goo.gl/zBlaR2

known problem - If you move very slowly "backwards" with constant "left/right" corrections you can reverse the arrow straight back but apart from that....

thanks so much its what i needed !
B
17
S
6
Posts: 245
Reputation: 1,784