Move a sprite from point A to point B?

  • Thank you very much gentlemen.

    I was hoping to avoid the lerp route as my last project ended up 1000 events and it became an unmaintainable mess.

    I just tried out rex moveTo pugin, and it works exactly as I need. I am very surprised that C2 have not added moveTo as a built in - its very very useful and saves a lot of work. I only hope it handles layer scaling.

    Pathfinding looks interesting, but for balls moving a few cm vertically in a bingo game, pathfinding is probably overkill (assuming it will treat all my UI elements as non solids?)

    Ill checkout liteTween also.

    All great suggestions - thanks again.

  • Without using unofficial plugins, you can use the Timer object to lerp (linear interpolation) between 2 values smoothly.

    For example;

    Set timer to 1 second

    every tick;

    lerp(x1, x2, timer.CurrentTime / timer.Duration)

    lerp(y1, y2, timer.CurrentTime / timer.Duration)

    and because the timer resets to zero, you need to add;

    OnTimer | set position to x2, y2

  • nutmix just use search, there's quite few posts about that

    @David Flook don't need timer for that

    Every tick: lerp(self.x,targetX,dt)

  • But to be clear, it's not the same movement right?

    Lerping self to target will create movement that starts fast and slows as it approaches the target. Is that correct?

  • shinkan

    The timer probably provides the easiest way of controling the movement speed, while still remaining fps independant.

    @David Flook

    Lerping that way will provide a linear movement, since dt is somehow constant, so no speed fluctuation.

  • nutmix

    pathfinding is now a behaviour very new so try it out

    it's official and not a third party plugin just look under behavious in an updated release

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • LiteTween offers basic to complex movement options.

  • Thank you very much gentlemen.

    I was hoping to avoid the lerp route as my last project ended up 1000 events and it became an unmaintainable mess.

    I just tried out rex moveTo pugin, and it works exactly as I need. I am very surprised that C2 have not added moveTo as a built in - its very very useful and saves a lot of work.

    Pathfinding looks interesting, but for balls moving a few cm vertically in a bingo game, pathfinding is probably overkill (assuming it will treat all my UI elements as non solids?)

    Ill checkout liteTween also.

    All great suggestions - thanks again.

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