Angle Tweening

» Sun Jan 20, 2008 11:20 am

If I wanted to set the angle between two objects gradually, how could I do that?

For example, I want my rocket to turn towards the cursor at a rate of 2 degrees per frame. How could I go about achieving this effect? (rather than the rocket simply pointing to the cursor all the time)
Some sort of function to get the angle between two objects would be handy (if there isn't already one there, I believe sin/cos/tan could possibly be used however I was always bad at trigonometry and the like D: )
B
3
S
2
G
4
Posts: 130
Reputation: 1,735

» Sun Jan 20, 2008 12:57 pm

You do simply like this:
-Create Sprite object
-Create Event "Always"
-Action "Sprite: Rotate 2 Degrees toward (MouseX,MouseY)"

If you want rocket to be slower change Always to Every 0.5s or something like that
B
4
S
2
G
4
Posts: 719
Reputation: 2,938

» Sun Jan 20, 2008 1:44 pm

Yep, you can use "Rotate towards position" or "Rotate towards another object." As Doppel pointed out there's a "Rotation amount" setting for both of those.

Alternatively, you could do something like:

[code:27t7u81m]
+Sprite Angle Less than 180
-Sprite: Rotate 2 degrees clockwise
[/code:27t7u81m]

"Set angle" makes the object jump immediately to whatever angle you pick, "Rotate (whatever)" sets the angle gradually.
Moderator
B
5
S
2
G
6
Posts: 4,348
Reputation: 10,971

» Mon Jan 21, 2008 12:22 am

Thanks for pointing that out, I feel kind of dumb for missing it.

Maybe I should sleep sometime, I hear it's beneficial.
B
3
S
2
G
4
Posts: 130
Reputation: 1,735