How to move an object to an exact position?

For questions about using Classic.

Post » Fri Dec 31, 2010 6:08 am

Hello, how would I move a sprite to a set position, say (230, 350) for example, at a set speed?
B
10
S
4
G
6
Posts: 76
Reputation: 3,615

Post » Fri Dec 31, 2010 6:22 am

There's a number of ways to go about this. The easiest way would probably be to give the object RTS behavior and then "Add Waypoint at Position".
B
2
G
3
Posts: 19
Reputation: 888

Post » Fri Dec 31, 2010 8:21 am

You could use the bullet behavior and set its angle towards the goal position. :D

I still believe there are better and efficient ways. That's just the way I did it. I still have a lot to learn about construct myself.
B
3
S
1
G
2
Posts: 86
Reputation: 997

Post » Fri Dec 31, 2010 11:33 am

[quote="JackieChann":155izyld]Hello, how would I move a sprite to a set position, say (230, 350) for example, at a set speed?[/quote:155izyld]

The easiest way to achieve this would be the "Move at angle" action of the sprite object. You can set the speed (pixel distance) and the angle to travel by. Use the angle expression like this:

angle(sprite.x,sprite.y,230,350)

and don't forget timedelta for your speed. :wink:
B
21
S
6
G
10
Posts: 1,024
Reputation: 7,445

Post » Fri Dec 31, 2010 7:44 pm

thanks guys! But I found a solution by using the path movement. I made an example for anyone who wants to see how I did it.

http://dl.dropbox.com/u/13338856/move%2 ... sition.cap
B
10
S
4
G
6
Posts: 76
Reputation: 3,615

Post » Sat Jan 01, 2011 3:25 am

Path movement is overkill for something simple like that. PR's solution is the most efficient.
Moderator
B
5
S
2
G
6
Posts: 4,348
Reputation: 10,971


Return to Help & Support using Construct Classic

Who is online

Users browsing this forum: No registered users and 4 guests