# torque towaards mouse

### » Wed Jul 08, 2009 12:33 am

is there a way to make in object rotate with torque
toward mouse position?
B
2
G
3
Posts: 15
Reputation: 880

### » Wed Jul 08, 2009 6:27 am

I assume you mean with physics behavior.

[code:30maf5fp]
+ Always
-> Sprite: Physics: Set torque 1000 towards angle(Sprite.X, Sprite.Y, MouseX, MouseY)
[/code:30maf5fp]

The angle(x1, y1, x2, y2) expression gives you the angle between two points.

You're also probably going to want to set the angular dampening in physics properties to 100%.
Moderator
B
5
S
2
G
6
Posts: 4,348
Reputation: 10,971

### » Wed Jul 08, 2009 7:47 am

the sprite is the object right?
if it is then its not working
B
2
G
3
Posts: 15
Reputation: 880

### » Wed Jul 08, 2009 9:21 am

Have you added a physics behavior to it?

B
3
S
2
G
5
Posts: 1,777
Reputation: 5,529

B
2
G
3
Posts: 15
Reputation: 880

### » Wed Jul 08, 2009 4:14 pm

You need to use the actual angle() expression here. You've just typed this in the angle box:

[color=#00BF00:g7zn6tkv]Sprite.X, Sprite.Y, MouseX, MouseY[/color:g7zn6tkv]

and you need to type this:

[color=#00BF00:g7zn6tkv]angle(Sprite.X, Sprite.Y, MouseX, MouseY)[/color:g7zn6tkv]

the [color=#00BF00:g7zn6tkv]angle(x1, y1, x2, y2)[/color:g7zn6tkv] thing is an expression that gives a number that represents the angle between the two points of Sprite.X, Sprite.Y and MouseX, MouseY. It's a math function that's figuring out the angle for you based on those four coordinates:

Moderator
B
5
S
2
G
6
Posts: 4,348
Reputation: 10,971

ok tnx it works
B
2
G
3
Posts: 15
Reputation: 880