Help with lerp

Get help using Construct 2

Post » Tue Oct 22, 2013 2:49 pm

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.


The capx file.
https://www.dropbox.com/s/25yoti1i9g8tzit/test10.capx

Thanks to anyone who is able to help.
B
42
S
21
G
31
Posts: 685
Reputation: 20,321

Post » Tue Oct 22, 2013 3:37 pm

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.
ImageImageImage
B
71
S
21
G
221
Posts: 3,649
Reputation: 124,227

Post » Wed Oct 23, 2013 6:32 am

@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!
B
42
S
21
G
31
Posts: 685
Reputation: 20,321


Return to How do I....?

Who is online

Users browsing this forum: No registered users and 8 guests