Help with lerp

0 favourites
  • 3 posts
From the Asset Store
Game with complete Source-Code (Construct 3 / .c3p) + HTML5 Exported.
  • Hello everyone,

    I wanted to create a drag and drop where the released object will return to its original position slowly. I used lerp for this. I got the effect I was looking for ultimately, but there was something weird.

    The object looks like it has return to its original position, but it hasn't. I use the disable drag and drop to confirm this and indeed it takes a couple of second to fully return to position. I am not sure how to fix this. Would love any help on this. Also, is this the right way to do this, or is there a more efficient way?

    This is the screenshot of the events.

    <img src="https://www.dropbox.com/s/3mgwecskcejzvtd/1.jpg" border="0" />

    The capx file.

    dropbox.com/s/25yoti1i9g8tzit/test10.capx

    Thanks to anyone who is able to help.

  • test10_BHT.capx

    You should have a bit of tolerance in your positioning rather than testing absolutes (X=oldX). Also you should only enable D&D in one place as X and Y will hit 0 separately, but you are still toggling it on and off.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • blackhornet thanks for your help!

    I've opened the file and studied it. Haha I am very very weak in programming so it took some time to understand, also had to look up what the abs function was. I think I've finally understood it.

    The abs event was referring to the tolerance you were talking about? Once the range to the original position is within 1, it automatically jumps back to the original position.

    Thanks for the drag and drop clarification as well. I only used it to test if it was taking a longer time to return to the original position, and I never paid attention to the scenario of x and y reaching 0 separately.

    Again, thank you very much for your help blackhornet. I really appreciate it!

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