move object to multiple positions

0 favourites
  • 5 posts
From the Asset Store
This is a single chapter from the "Construct Starter Kit Collection". It is the Student Workbook for its Workshop.
  • 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!


  • i've forgot, i've had to use a nice and smooth move, like progressive but fast acceleretion and deceleration!

  • Sounds like this could help (not sure, as I have not used it myself)

  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • 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

  • 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!

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)