1. Hello Guest! It's with a heavy heart that we must announce the removal of the Legacy GMC Archive. If you wish to save anything from it, now's the time! Please see this topic for more information.
    Dismiss Notice

Making an object move with a pause between steps

Discussion in 'Programming' started by Darent, Jan 21, 2018.

  1. Darent

    Darent Guest

    I have a question, I want to make an object that travels trough a path or maybe just move to one side (like using a while loop and adding some x += 1; somewhere)
    but my issue is that I want the object to travel certain distance, stop, wait for 1 second or any time I want, and then return or even keep going... I saw paths and you can make objects follow them but, is there a way to make the object stop and then resume the movement?

    something like...
    x_speed = -1;
    wait(1 second);
    x_speed = 0;
    wait(1 second);
    x_speed = 1;
    wait(1 second);
    x_speed = 0;

    or what else can I use to make this kind of behavior? I saw something about collisions but... there's nothing on my Room that the object can collide with... and also I'm looking for the pause/wait functionality...

    thank you in advance!
     
  2. JFitch

    JFitch Member

    Joined:
    Sep 28, 2016
    Posts:
    428
    You could use an alarm to toggle a variable that says whether it's moving.
    Code:
    /// Alarm 0 Event
    moving = !moving;
    alarm[0] = room_speed;
    Then, use this for your moving code.
    Code:
    if (moving) {
        // normal moving code
        } 
    else {
        speed = 0;
        }
     
  3. TheouAegis

    TheouAegis Member

    Joined:
    Jul 3, 2016
    Posts:
    7,145
    Or if actually on a path, path_speed=0
     
  4. Darent

    Darent Guest

    Oh! Thank you very much!!!
     

Share This Page

  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice