Hundreds of features to explore
Games made in Construct
Your questions answered
Popular & trusted by schools and Universities world-wide
Construct 3 runs in the browser & works offline
Students do not need accounts with us
Free education resources to use in the classroom
World class complete documentation
Official and community submitted guides
Learn and share with other game developers
Upload and play games from the Construct community
Game development stories & opinions
How do i move an object from point A to B in a linear fashion in x amount of time rather than speed without 3rd party plugins?
Develop games in your browser. Powerful, performant & highly capable.
Figured it out.
totalTime = 3
if currentJourneyTime < totalTime
add dt to currentJourneyTime
lerp(startX, endX, currentJourneyTime/totalTime)
determine the vectorx, by doing curent x - target x
determine the vectory, by doing curent y - target y
on every tick
set x to self.x + vectorx * self.timevariable * deltatime
set y to self.y + vectory * self.timevariable * deltatime
Intersting solution, thank you.
However i prefer my method as i'm able to easily define the movement state by checking currentJourneyTime without any distance checks.
If currentJourneyTime < totalTime then objects moving, else objects reached destination.
Depends on what the application is.
Your movement will not be linear if your target moves, it will be homing and accelerate/decelerate to be able to hit the target at the 3 second mark no matter what it could even go backwards if the target gets closer, since you're not defining target as self.target