SOLVED - How do I track movement with TileMovement?

0 favourites
  • 11 posts
From the Asset Store
For dark exploration, survival, horror, platforms, adventure, fantasy games.
  • I have an idea for a turn based game using TileMovement.

    But, to do the idea I have I need to be able to limit the movement of player each turn and I also want to do an action after each movement.

    What's surprising me is when I look at the actions under TileMovement I see: "can move" and "is moving", but nothing for "has moved".

    What is the best/easiest way to:

    - Limit movement per turn?

    - Trigger an action after each movement?

    Tagged:

  • I don't remember if gridtargetx and gridtargetx are preserved after arriving, but try a combination of

    Is moving (inverted)

    And gridtargetx = gridx

    And gridtargety = gridy

    If they aren't, you can use a variable to keep track of them instead.

    Limiting movement can be done as a condition on input checking a variable that keeps track of available moves, which can be updated upon inputting a movement.

  • I just did a search and can't find anything on "GridTarget".

    It seems like there should be some action I can trigger, when a tile movement has taken place, but I can't find it.

    If I had that, then I could easily setup a variable to track how many times I've moved and, subsequently limit movement.

  • Try Construct 3

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

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

    GridTargetY

    Return the grid cell the object is currently moving towards, by its column and row.

    construct.net/en/make-games/manuals/construct-3/behavior-reference/tile-movement

  • Thanks for the link. I'm still stuck though. I'm not sure why this is so confusing to me.

    I can't seem to figure out how to write the event and action that will trigger after a tile movement has occurred.

    Does anyone have any examples of this in action I can take a look at?

  • I can't seem to figure out how to write the event and action that will trigger after a tile movement has occurred.

    Does anyone have any examples of this in action I can take a look at?

    do you mean you want to move the tile background?

    and have a way of triggering next movements?

    Just explain game a bit and then i should be able to help.

    Radkampfwagen

  • do you mean you want to move the tile background?

    and have a way of triggering next movements?

    Just explain game a bit and then i should be able to help.

    Radkampfwagen

    No, I don't want to move the tile background.

    I have a Sprite Object named "Player" with a TileMovement Behavior. I can then use the arrow keys to make him move. This works great.

    However, this will be a turn-based game, so I want to be able to limit the number of squares the player can move each turn.

    In addition, after each tile movement, I would like to be able to do some other tests.

    So, I just need someone to show more or link me to an example, where I can trigger an action after a TileMovment is complete.

  • Thanks everyone for your help so far, I think I finally figured out a pretty easy solution.

  • The above solution mostly worked, except the default tile movement controls let you hold down an arrow key and keep moving - which prevented the end of move action from triggering.

    So, I had to turn off the default controls and then add this:

    And, now, I think everything is working as I hoped.

  • yea or you could have done:

    kb-keyboard

    global variable default ==0

    2 conditions and actions for every event

    1)kb on right arrow pressed

    2)and global variable==less than >=4

    --------------------------stim right movement

    --------------------------add 1 to global variable

    1)kb on left arrow pressed

    2)and global variable==less than >=4

    --------------------------stim left movement

    --------------------------add 1 to global variable

    1)kb on up arrow pressed

    2)and global variable==less than >=4

    --------------------------stim up movement

    --------------------------add 1 to global variable

    1)kb on down arrow pressed

    2)and global variable==less than >=4

    --------------------------stim down movement

    --------------------------add 1 to global variable

    (4 is the max moves)

    Uses 4 events

    Radkampfwagen

  • Thanks for the other suggested solution.

    That's one of my favorite things about coding - there are almost always multiple ways to solve a problem.

    At the moment, I'm coding a puzzle game and actually coding it sometimes feels like I'm solving puzzles. :)

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