How do I movement in a grid(example)

0 favourites
  • 4 posts
From the Asset Store
Run and Jump in 3 Dimensions! Take your platformer to the next level!
  • Hello guys,

    I am trying to make 2d RPG game with grid movement (one square movement only allowed)

    I already done grid movement for player. I can move all 4 directions and if there is collision on the right for example water I can't even start moving in that direction.

    I found pretty hard to do that on monster.

    What I want to do:

    • Monster can move in 4 directions grid (done but not perfect)
    • Monster can move 1 square which is 16 pixels or don't move at all
    • When there is collision on the right don't allow him to move there, go around that if chasing player.
    • Player chasing (done, but not perfect, sometimes monsters move not 16pixels but less and they are out of their square)
    • When monster will catch player, so player is 1 square from monster, stop moving to him (done, but not perfect, sometimes monster is moving onto player and sometimes monster is out of his grid)
    • When player is not in monster's LOS he should get back to spawn point. (not done)
    • Monster can't go on another monster grid and if there is collision he should always stay in his grid(center of 16pixels square) or go around another monster.
    • Monster should go back to spawn point if not chasing player(grid movement one square at a time)

    What is done:

    • Player can move in grid and collisions are done perfectly.
    • Player
    • Monster is chasing player(target) if he is in certain LOS. Monster is moving one grid at a time(16pixels) with little stop between each move.
    • Monster if doesn't have player in LOS is moving in randomly chosen directions.
    • If monster is near player, is stopping(he should be able to still move, but not into player, but it is too hard)

    What I struggle to do:

    -Monster following player until he is in 1grid LOS, if player will move monster will start chasing again

    now: monster jumps into player and he is not always in his grid.

    -When monster have collision for ex. on the right don't allow him to move there, go around that if chasing player.

    now: When monster in collision with another monster or ground object, he is moving pixel by pixel or stopping.

    Can someone help me with that?

    I found that movement is hardest part for especially on monsters and it already consumed a lot of my time.

    I think that if I complete that part the rest won't be that problem since Construct2 is very enjoyable for me.

    Scan:

    https://www.virustotal.com/#/file/a6455c4b0d44b9764af6cc59702db2a1f130f217e77b40f7e654f4ba0f379f36/detection

    Game: https://drive.google.com/open?id=1vWpEP9UCzIjGVhJTy1BOo9edwPU-_N4M

    Thanks for every advice

    Bartek

  • This game will be very hard to make without the pathfinding, but the standard behavior doesn't work with tilemaps.

    There are a few plugins for grid-based pathfinding, you definitely should check them out:

    Also, Bullet behavior is inaccurate and hard to control. Instead of Bullet, use MoveTo, it's a great behavior, very easy to use:

    Why do you have like 6 or 7 tilemaps on top of each other? Usually you need 1 tilemap with Solid behavior where you define tiles like walls and trees. And another tilemap with grass and all other scenery objects that you can walk on.

  • Hi, I don't have a specific solution for your question, but I recommend investing time in learning Rex's Board plugins and behaviours. I've used this extensively (although I'm using this for isometric, the principle of the plugin is the same for orthographic) and I found they solve many of the problems you describe.

    For example, it is easy to query if a particular 'chess' piece is a neighbour of another (instead of doing your own function). You can also query how many movement tiles away two 'chess' pieces are.

    Rex has also implemented pathfinding, too.

    However, it takes a bit of patience to learn all the capabilities because the Rex's 'Board' system is composed of several plugins and behaviours. You don't need to use all of the plugins or behaviours, just the ones you think you need. I really recommend giving it a go. If you're stuck with an issue, you can just ask, and perhaps I (or even Rex) could offer some suggestions using the Board system.

    (I've always wanted to do a Rex Board tutorial series, but I haven't had enough time. )

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • dop2000 I shouldn't have 6/7 tilemaps I just messed up smth while I was starting that project and I didn't understand few things. I will definitely solve this

    Thanks for the examples I will definitely check them and try to implement.

    faulknermano

    It looks like I was trying to invent a wheel, but someone done it far better than I would ever done. Thanks for that, I will surely Investigate the Rex's plugins.

    ahh I love you guys. Thanks both of you for replies

    I will give feedback after some time.

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