Action Loop?

  • #1, by tangerinedogThursday, 28. March 2019, 17:49 5 years ago
    I want an object to move a certain distance, then jump back to the start instantly and repeat.

    How do I get the program to wait until the forst action part is finished to perform the second one?

    Newbie

    12 Posts


  • #2, by afrlmeThursday, 28. March 2019, 18:50 5 years ago
    By object do you mean the actual object or just the image/animation linked to the object?

    Either way, you can use the move object to action part or you can use the to() Lua script function.

    If you want to use the move object to action part, what you should do is something along the lines of this...

    move object x to x/y position over x time
    pause for x time (same time or greate than you specified in the move object action part)
    jump to action part #1

    that's more or less how the action parts should look. insert those into a called by other action type action & call it as needed - don't forget to manually stop that action with the quit action action part when you no longer need it to loop.

    Imperator

    7278 Posts

  • #3, by esmeraldaFriday, 29. March 2019, 09:00 5 years ago
    There are also the curves to move an object or animation.
    Totally forgot about them until I rediscoverd a test project where I used a curve.

    Key Killer

    508 Posts

  • #4, by afrlmeFriday, 29. March 2019, 11:10 5 years ago
    There are also the curves to move an object or animation.
    Totally forgot about them until I rediscoverd a test project where I used a curve.

    Aye, there's those too, though they are somewhat more complicated, but yeah I forgot about them too. grin

    They are useful as you can draw curved paths which anything that can be moved can follow. There are 3 types of curves available:

    1. Curve: curve with a start & end point - object/image will move from the start to the end or loop back to the start once it reaches the end.

    2. Continuous curve: this is useful for creating circles/figure eights, & other crazy shapes. The end point needs to be reconnected back to the starting point to create a continuous loop.

    3. Curve via control points: I don't remember what this one is for.

    You also need to include a snippet of code like this inside of an execute a script action part to make the curve work. Replace the ActiveAnimation line with whatever it is thatt you want to move. Like I said, it's more complicated than simply moving something with action parts or the to() Lua function.
    startCallbackTween(1800, function(x)
    
      local pos = game.CurrentScene.Curves[1]:curveAt(x)
    
      local direction = game.CurrentScene.Curves[1]:curveDirection(x) - 1.57
    
     
    
      ActiveAnimations["m001_bulb"].AnimationCurrentPosition = {x = pos.x - 150, y = pos.y}
    
     
    
    end, easeLinearIn, true, true)


    Imperator

    7278 Posts

  • #5, by tangerinedogSaturday, 30. March 2019, 00:58 5 years ago
    By object do you mean the actual object or just the image/animation linked to the object?

    Either way, you can use the move object to action part or you can use the to() Lua script function.

    If you want to use the move object to action part, what you should do is something along the lines of this...

    move object x to x/y position over x time
    pause for x time (same time or greate than you specified in the move object action part)
    jump to action part #1

    that's more or less how the action parts should look. insert those into a called by other action type action & call it as needed - don't forget to manually stop that action with the quit action action part when you no longer need it to loop.
    This is almost it (I didn't know there was a pause function... I only ever thought to look for wait or set timer...).

    Only it doesn't cooperate...

    I put in:
    move object by x 100
    pause
    move object by x -100
    jump to action part #1

    What it does is move by 100, pause for nothing near the amount of time I've set, then continue moving towards positive x indefinitely.

    Edit: Eureka!

    move object by x 100
    pause
    move object by x -100
    pause AGAIN (for 0 ms, but whatever, it works)
    jump to action part #1

    Newbie

    12 Posts

  • #6, by afrlmeSaturday, 30. March 2019, 11:17 5 years ago
    Visionaire iterates through the action parts in order, & will only wait before executing the next action part if a pause is used or if an action part contains a built in pause or has an option to pause/wait until that particular action has finished. There probably wasn't enough time for the engine to execute the last move action before it looped & it got overwritten by the other move action part.

    Imperator

    7278 Posts