How To Make An Object Move Left To Right In A Loop?

Discussion in 'How Can I...?' started by CartelGheto, Apr 6, 2020.

Tags:
  1. CartelGheto

    CartelGheto Boxer

    Joined:
    Apr 5, 2020
    Messages:
    1
    Likes Received:
    0
    I am trying to get an object to move from left to right in a loop.Can anyone help?
     
  2. Gamebox

    Gamebox Boxer

    Joined:
    Apr 27, 2020
    Messages:
    11
    Likes Received:
    2
    Hi,

    You add a position limiter node.
    Connect to the create dot from the start node
    and you change the code where it says (click on the pen top right corner of the node)
    In the update function:

    if(_max.x != null && pos.x > _max.x){
    pos.x = _max.x;
    }

    to

    if(_max.x != null && pos.x > _max.x){
    pos.x = _min.x;
    }

    this way when it reached the max position allowed ,it resets to the minimum position on the x axis
    (if your movement in on the y axis do that for pos.y)

    Combine with a Move node
     

Share This Page