Need help in Move to behavior

0 favourites
  • 5 posts
From the Asset Store
Game with complete Source-Code (Construct 3 / .c3p) + HTML5 Exported.
  • I have a 2 sprites "track" and "Player".

    Player will move (forward or backward) over the track when a track is click

    This part has been done

    The problem is I want to move player over the track one by one (currently its running smoothly from current track to clicked track) I created "scale" animation on "player". So i want from player to move each track by playing "scale" animation each time when it start moving.

    for example player's current position is track 0 and target position is 10 then i want to move player to track 1 and play "scale" animation then move to track 2 and play "scale" animation again and so on

    How can i do this?. Please help

  • Instead of moving it straight to target pos, you set up a loop that runs move to on a local variable value starting from player pos, then +1 each time until it matches with target pos. So if you are at 1 and target 5, you set a local var to playerpos, add 1 and move to that tile. Then run a check, if local var not equal to target pos, so 2 not equal to 5, run it again - add 1 and move to that tile.

  • sorry for the late reply.

    i'm not getting it properly. I tried it by

    Player | isMoving

    === localvariable "move" ====

    for "X" from player.pos to target = set "move" to player.pos

    if "move" is less then target = Add 1 to "move" & set player.pos to "move"

    player.pos = track.pos = player move to track

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • if "move" is less then target = Add 1 to "move" & set player.pos to "move"

    player.pos = track.pos = player move to track

    I meant use : move to track where track.pos = "move" until player.pos and track.pos are the same so you have reached your destination

    Also all of this within an 'is moving' condition its going to keep running every tick which sounds like it wouldn't work. Try running the loop in a trigger once situation.

  • its doing the same thing which my above screenshot events doing

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