torque towaards mouse

For questions about using Classic.

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

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

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

Post » Wed Jul 08, 2009 9:21 am

Have you added a physics behavior to it?

if so, and you've added the event, upload a .cap.
B
3
S
2
G
5
Posts: 1,777
Reputation: 5,529

Post » Wed Jul 08, 2009 3:19 pm

B
2
G
3
Posts: 15
Reputation: 880

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



For more information on math expressions, check out the [url=https://sourceforge.net/apps/mediawiki/construct/index.php?title=System_Expressions#Math:g7zn6tkv]wiki[/url:g7zn6tkv].
Moderator
B
5
S
2
G
6
Posts: 4,348
Reputation: 10,971

Post » Wed Jul 08, 2009 4:28 pm

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


Return to Help & Support using Construct Classic

Who is online

Users browsing this forum: No registered users and 6 guests