How to rotate one object towards another object?

» Tue Mar 10, 2009 11:20 am

Hi!
Please, help me to solve one problem.
There is a scrolling platform game, main character and something (may be arrow) in top-right(always), which shows where is the door(exit), for example. Question is how to make that arrow always rotates towards the door depending on the main character's position
I don't know, but "set angle towards an object", "rotate towards.." etc, doesn't work properly - it rotates arrow only once in the beginning of the game.
Thanks!
B
2
G
3
Posts: 30
Reputation: 910

» Tue Mar 10, 2009 11:21 am

You want it to be always active, so put that action in an event with "Always" condition. That way it will always update the angle.
B
62
S
21
G
12
Posts: 1,910
Reputation: 13,155

» Tue Mar 10, 2009 11:44 am

I put this action in "Always" condition, but it doesn't work. ..

Please, look at it. There is pink arrow and red box in right-bottom. The arrow must rotates towards the box. Look at conditions. But it doesn't...

B
2
G
3
Posts: 30
Reputation: 910

» Tue Mar 10, 2009 11:49 am

The default angle is 0, which is facing right. The image of the arrow faces north, so it'll always look like it's off by 90.
B
3
S
2
G
5
Posts: 1,777
Reputation: 5,529

» Tue Mar 10, 2009 12:14 pm

Rich,
Ok. I understood you.
Now there is right angle (not off by 90).
But the arrow doesn't always rotate. It must be like.. compass arrow! Slightly to the right, slightly to the left - always changes angle when the sprite moves left or right, up or down.

Do you understand me?
B
2
G
3
Posts: 30
Reputation: 910

» Tue Mar 10, 2009 12:20 pm

Assuming that you have Arrow, Door and Player sprites:
[code:2brvn5nu]+Always
> Arrow: Set Angle to angle(Player.X,Player.Y,Door.X,Door.Y)[/code:2brvn5nu]

That will always point to the door in relation to the player, not arrow itself.
B
62
S
21
G
12
Posts: 1,910
Reputation: 13,155

» Tue Mar 10, 2009 2:15 pm

Mipey,
Wow! Thank You so much!!!
B
2
G
3
Posts: 30
Reputation: 910