move object to multiple positions

Get help using Construct 2

Post » Tue Nov 05, 2013 7:56 pm

Hi everyone. i'm stuck on my project, i don't know how to solve my problem, and what tool should i use.

I have a sprite "X". the position of this sprite is 500,500 , and i want to be able to move that sprite to multiple exact positions (1 position =1px) , depending of clickable objects. for exemple, when i click on "a" object, the sprite have to move to point A, when i click on "start"object, the sprite have to move to start position, but i also want to be able to move it to B C or D position.

i've tried to add a bullet behavior on my object, set bullet angle to 210, then stop after the bullet have run more than 500px, and inverted conditions to move object to start position. unfortunately, it wasn't a good idea, aiming was bad. so i've tried to set angles and compare X and Y position, but the problem is the same, not really good aiming, and going back to start was impossible: i miss the spot.i've thinked about the trigger " is overlapping another object", but with the lack of precision, after some movements, i missed the object and scrolling were going far away...Anyway, having less precision, like using "x >= 500" triggers, won't work, because of multiple positions it's really important to perfectly spot the pixel. how can i do this? should i use pathfinding ?

i'm searching in the forum and tutorials for 3 hours now, and will continue until i find the best way to do this.

thank's for helping me. any idea can help!


alex
B
4
Posts: 7
Reputation: 214

Post » Tue Nov 05, 2013 8:01 pm

i've forgot, i've had to use a nice and smooth move, like progressive but fast acceleretion and deceleration!
B
4
Posts: 7
Reputation: 214

Post » Tue Nov 05, 2013 10:46 pm

Sounds like this could help http://www.scirra.com/forum/behavior-zigzag_topic46286.html (not sure, as I have not used it myself)
Visual Novel 'Engine' in 100 Events
if you ever have to choose between buying Construct 2 on scirra.com or on Steam, read this: Review
B
22
S
9
G
1
Posts: 787
Reputation: 3,786

Post » Wed Nov 06, 2013 1:03 am

You are going to want to do some searching on "Lerp" which is a math concept that allows you to move an object over time with a nice start/end speedup/slowdown effect

but basically it will be

On "DestinationObject" clicked ->
(Sub event)Every Tick -> "object that needs to move" set position to

X = Lerp ( "object that needs to move".X , DestinationObject.X , 0.5*dt)
Y = Lerp ( "object that needs to move".Y , DestinationObject.Y , 0.5*dt)

If you play with the value 0.5*dt you can make it faster/slower - eg: try 0.3 or 0.7
B
87
S
44
G
16
Posts: 1,002
Reputation: 17,932

Post » Wed Nov 06, 2013 1:07 am

thank's guys, i've found a weird way to do what i want,too many events for a basic action, and no acceleretion/deceleration, so not really nice. so i will try justifun solution. mindfaQ, thank's for your link, but unfortunately i can't find a way to use it to reach my goal. Anyway, i will try to work on "lerp" and ask for more help if needed!
B
4
Posts: 7
Reputation: 214


Return to How do I....?

Who is online

Users browsing this forum: David181, evillair and 57 guests