0 Favourites

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

  • 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

  • Construct 3

    Buy Construct 3

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

    Buy Now Construct 3 users don't see these ads
  • 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 <img src="{SMILIES_PATH}/icon_e_biggrin.gif" alt=":D" title="Very Happy"> 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

  • 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!

  • 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

  • tarek2

    Thanks, this problem was quite a challenge for me! I had to stop and seriously think about it.

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)
Similar Topics Posts Views Last Post
Unread hot topic
564 105,179
rexrainbow's avatar
rexrainbow
Unread hot topic
167 14,485
DMT2005's avatar
DMT2005
Unread hot topic
123 14,867
Zebbi's avatar
Zebbi