How do I make this 4-way movement work?

0 favourites
  • 12 posts
From the Asset Store
Units do not overlap each other and use different ways if there are several free ways.
  • So i have a problem creating a 4-way top down movement. My player (black box) gets stuck on the edges and also cant move along the wall on all 4 sides. How do i make this work also. When you press the direction player has to move in that direction until it hits the wall, you also cant change direction mid movement, only when he hits the wall.

    Project:

    [attachment=0:3h4m1ttu][/attachment:3h4m1ttu]

  • Try instead of making your own movement events using the 8-way movement behavior and setting its properties to 4-way movement (up,down,right,left) and put the keyboard control events inside a group (Movement). Then give your wall a solid behavior so it stops the player. Start layout with "Movement" group active then deactivate group "Movement" upon a movement key being pressed and only activate the group on a detected collision/overlap with a wall.

  • Yea that would work but still dosen't fix the issue where if i'm next to a wall and want to move along side the wall i dosent move cause it check for collision. Thats the main issue i have and have no idea how to fix it.

  • Hi, not sure if im missing something but would this work? - requires no code as such other than the built in behaviours.

  • Nop this is not what i meant. I couldve done this on my own :=).

    If this helps:

    Lith - iOS Gameplay Review - type this in youtube (i cant post links to little rep )

    I want to make that type of movement.

  • Yeah I thought it seemed too simple

    I see what you mean now, off the top of my head if the walls and player was both set to solids, and the player also had the 'bullet' behaviour on him (setting the bullets angle and speed based on the direction pressed) , then an event for when he hits a solid, set his speed to 0

    To fix an issue where he might not move due to being right next to a wall, you could always add an event to check when his bullet speed is 0 (ie stopped) , move him more central in the tile / empty square hes in, only needs to be by a pixel or 2 so wouldnt be noticed.

  • I understand what you mean. I will give this a try and i hope it will work.

  • Try Construct 3

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

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

  • So i'm currently working on the solid and bullet beh. The thing i noticed is i cant make the player move up and down. Also how can i check from wich direction i hit the wall.

    So if i hit it from right to make player.x - 1

    if i hit from top make player.y - 1

    etc...

  • OK, I got it working using some creative thinking.

    Try this out and see if it doesn't feel like the video shows.

  • Thanks that works. Its still weird how sometimes the player get right close to the wall with no pixels in bettween, and yet sometimes there are like 1-2px bettween player and the wall. Yet it still works perfectly. Soo weird.

  • That is because I just threw the collision detection sprites onto the player and didn't tweak them. Adjust the player and collision sprites image points till the distance is the same.

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