Point A to Point B via time?

0 favourites
  • 3 posts
From the Asset Store
Connect the dots in the correct order and draw happy animals!
  • hey guys i'm having a bit of trouble figuring this out, hoping somneone can help

    I'm looking at making a sprite move from point A to point B.

    I will be having objects in an array move from different points by taking the distance and time and setting the sprite position by time left.

    For instance [Sprite 1] is going to be going from Point A to Point B (back and forth) i can work out the distance between them and divide that by the speed the sprite can move (variable) and then when i need to display the sprite image i can set its position from the time remaining from the array (which will be the only thing updated)

    So if viewing the 'graphical' layout it will set sprites position every tick from the time left stored in the array.

    Hope this makes sense and hope you guys can help.

    Thanks in advance ;)

    EDIT: the time it takes to travel will be updated by the array, so [every 1 second] subtract 1 from time left in array

    Edit2: so if i load layout while sprite is halfway through journey how would i set the X/Y co-ords

  • I'm not sure I fully understand your post, especially the edits. But here is how you can set sprite position between two points based on time passed and total time it takes to travel:

    progress = clamp(elapsedTime/totalTime, 0, 1)
    Sprite set position to 
     x: lerp(PointA.x, PointB.x, progress)
     y: lerp(PointA.y, PointB.y, progress)
    
  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Yeah sorry i'm pretty bad at explaining things, But that is exactly what i was after!!!!

    Thanks a lot

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