How to rotate one object towards another object?

For questions about using Classic.

Post » Tue Mar 10, 2009 11:20 am

Hi!
Please, help me to solve one problem. :roll:
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

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

Post » Tue Mar 10, 2009 11:44 am

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

This is very simple example - [url:3ik9trvr]http://willhostforfood.com/?Action=download&fileid=58261[/url:3ik9trvr]
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... :(

What is your opinion?
B
2
G
3
Posts: 30
Reputation: 910

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

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

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

Post » Tue Mar 10, 2009 2:15 pm

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


Return to Help & Support using Construct Classic

Who is online

Users browsing this forum: No registered users and 1 guest