move object in specific time

This forum is currently in read-only mode.
From the Asset Store
This is a single chapter from the "Construct Starter Kit Collection". It is the Student Workbook for its Workshop.
  • I have another problem.

    I can easy move object - on click, then I "set position" on X and Y and object move where I want.

    But can I make it that it will took for example 2 seconds? so object will move smoothy?


  • If you want an object to move like that, you might want to go for bullet behavior and set direction and speed.

    Is this what you are asking for?

  • I tried that, but not succesfull :(

    I have on object, for example on place XY(50,50). and when I click on it, I want this object move to XY(100,100), but not immediately, but for example for few seconds.

    I dont know how to set bullet, for me it moves only from one place to right and does not stop it on place where i want

  • The rotate expression actually works well for this. It's designed for angles but it can be used for anything pretty much.

    Try setting the X and Y to: RotateAngle(Sprite.X, 100, 2)

    Where Sprite.X is the starting position (so Sprite.Y for Y), and 100 is the destination, and 2 is the pixels to move by each tick.

    Hope that helps!

  • I tried it:

    but still it does not work for me :( dont know what i am doing wrong

  • Hi try using RTS behavior, set all params until you get desired response, dont forget unmark rotation

    look on this example how i move the item for each menu option...

  • thanks, rts behavior works ok and it is what i need,

    thanks again!

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • joxer

    I recommend reading the Construct wiki. It helps a lot understanding the concepts of "tick based" and "time based". The key to time based actions is "TimeDelta".


    Just in case you're curious, there's another way to move something over time by combining "lerp" with "TimeDelta".

    lerp(a, b, t) interpolates between a and b at t, with t ranging from 0 to 1. t=0 results in a, t=1 results in b.

    If you add TimeDelta to a zero-initialised variable on every tick, it will be 1 after one second. To let it reach 1 after two seconds, you would add '0.5 * TimeDelta' instead.

    This would move the sprite horizontally from 200 to 100 in two seconds (pseudo code):

    + myVariable less than 1

    -> Add 0.5 * TimeDelta to myVariable

    -> Set Sprite.X to lerp(200, 100, myVariable)

    EDIT: And if this is too confusing, it might even give you more accuracy if you'd let myVariable count to the needed seconds. But then you need to divide myVariable by the correct number in "lerp". This example would move horizontally from 64 to 211 in 3 seconds:

    + myVariable less than 3

    -> Add TimeDelta to myVariable

    -> Set Sprite.X to lerp(64, 211, myVariable / 3)

  • tulamide: thanks,

    your construct knowledges are awesome!

  • tulamide thanks, that's a nice way of doing it too!

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