How do I move object-1 at the exact X and Y of object-2

Get help using Construct 2

Post » Tue Aug 09, 2016 2:11 pm

Hi guys! i know probably will be easy to do but i tried everything honestly
How do I move an object at the exact X and Y of different object) ? that is continuosly moving with the shine behavior, looks like the shine moves the object-2 but the X and Y don't move so when the object-1 goes up or down they are not coordinated.
example: object-1 moves like a lift up and down in a straight line that are always moviing but always overlaping the object-2, and moves just the size of the object-2. I managed to do it at the end after 4 days trying with lerp but it moves very fast and i have no control over the speed, i tried to lerp at lower speed but then it loses the angle and dosn't go stright, it starts to do a curve

my head is gone explode any help will be much appreciated, thanks very much in advance.
i will leave the capx if any one wants to have a look, to reproduce it: arrow key up is down moves the red arrow stright through the body of the object-2 without doing any curve, i need to the same but slower basically with more control of the speed like smooth movement
https://www.dropbox.com/s/klo0cu0xo0trgqm/example1move.capx?dl=0
B
40
S
23
G
83
Posts: 298
Reputation: 45,844

Post » Tue Aug 09, 2016 5:44 pm

@tarek2

Hi! Is this what you are trying to do?

https://www.dropbox.com/s/sma8uututdw7l ... .capx?dl=0
B
17
S
9
G
5
Posts: 74
Reputation: 4,145

Post » Tue Aug 09, 2016 9:54 pm

SimoneT wrote:@tarek2

Hi! Is this what you are trying to do?

https://www.dropbox.com/s/sma8uututdw7l ... .capx?dl=0


sorry i just woke up now,

Wow that is exactly what i was looking for :D thank you so much @Simone defenetly i wouldnt guess it by my self, and with 3 line of code amazing, I had in the original capx like 100 line of code trying to do this jeje, just a quick question the last bit of code ^dt,0,1 what it means? from clamp(LerpPercentage+ 1-LerpSpeed^dt,0,1) I just triying to understand what is happening so i can remember it better
B
40
S
23
G
83
Posts: 298
Reputation: 45,844

Post » Tue Aug 09, 2016 10:21 pm

@tarek2

Well, "clamp(x,y,z)" keeps the x variable between y and z. Since we don't want the arrow to shoot or drop off the pendulum, I set the min(y) to 0 and the max(z) to 1. If you want the arrow to move with a smooth motion, you can replace the lines with:

Keyboard arrow is down => lerp(LerpPercentage,1,1-LerpSpeed^dt)
Else => lerp(LerpPercentage,0,1-LerpSpeed^dt).

Going up, the arrow will ease into 1 and going down into 0.

Or only change 1 of the 2 lines. Play around with it and figure out what you like best!

Hope this helps!
B
17
S
9
G
5
Posts: 74
Reputation: 4,145

Post » Tue Aug 09, 2016 11:07 pm

SimoneT wrote:@tarek2

Well, "clamp(x,y,z)" keeps the x variable between y and z. Since we don't want the arrow to shoot or drop off the pendulum, I set the min(y) to 0 and the max(z) to 1. If you want the arrow to move with a smooth motion, you can replace the lines with:

Keyboard arrow is down => lerp(LerpPercentage,1,1-LerpSpeed^dt)
Else => lerp(LerpPercentage,0,1-LerpSpeed^dt).

Going up, the arrow will ease into 1 and going down into 0.

Or only change 1 of the 2 lines. Play around with it and figure out what you like best!

Hope this helps!




Cool, thank you so much for your time and for sharing your knowledge :)
B
40
S
23
G
83
Posts: 298
Reputation: 45,844

Post » Wed Aug 10, 2016 12:13 am

@tarek2

Thanks, this problem was quite a challenge for me! I had to stop and seriously think about it.
B
17
S
9
G
5
Posts: 74
Reputation: 4,145


Return to How do I....?

Who is online

Users browsing this forum: Congrats2u and 23 guests