8-Direction Movement & Diagonal Collisions

  • Hi guys, I'm having a collision problem! My player sprite is moved with 8-Direction controls and I'd like my game to have a lot of diagonal walls (Solid behaviour). I'd like it if the player could 'slide along' the wall if you move up or down whilst pressing into it; it works fine to slide downwards along the wall, but if you attempt to slide UP the wall and press into it, the player collision object just stops dead. I realise this is a hard concept to describe, so I made a (very crap) illustration to help:

    And I have noooo idea how to get the upward diagonal motion I need. Does anybody have any ideas??

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Hi guys, I'm having a collision problem! My player sprite is moved with 8-Direction controls and I'd like my game to have a lot of diagonal walls (Solid behaviour). I'd like it if the player could 'slide along' the wall if you move up or down whilst pressing into it; it works fine to slide downwards along the wall, but if you attempt to slide UP the wall and press into it, the player collision object just stops dead. I realise this is a hard concept to describe, so I made a (very crap) illustration to help:

    And I have noooo idea how to get the upward diagonal motion I need. Does anybody have any ideas?? <img src="{SMILIES_PATH}/icon_e_sad.gif" alt=":(" title="Sad">

    try this awesome capx for 8dir wall slide maded by R0J0hound

    https://drive.google.com/open?id=0BwNG7 ... WVMRXliNjg

  • Thanks for the link! However, I ran that capx three times and every time I managed to get the player sprite stuck in a wall almost immediately. It seems that it doesn't work very well?

  • Thanks for the link! However, I ran that capx three times and every time I managed to get the player sprite stuck in a wall almost immediately. It seems that it doesn't work very well? <img src="{SMILIES_PATH}/icon_e_sad.gif" alt=":(" title="Sad">

    sorry wrong capx... <img src="{SMILIES_PATH}/icon_redface.gif" alt=":oops:" title="Embarrassed">

    this

    https://drive.google.com/open?id=0BwNG7 ... 1dIcVRQNFE

  • Ah! That does work rather well. It was daunting to reproduce in my game, and I was thinking the whole time "this will never work", but it turned out that it did work quite well actually in the end!

    Thank you to you and R0J0hound! What a C2 wizard

  • Hmm. On further testing it seems that I'm having a little problem with R0j0's collision system. For some reason it works perfectly well and smoothly when approaching diagonals from the side, but when colliding with something from above, my player sprite now judders uncontrollably. This doesn't happen to me in the original capx, just in my game. Any idea what might be causing this? Presumably it's something about my project that causes this, but I can't think what could possibly be a reason...?

  • mikehive

    If the events are the same and the image points are placed in a clockwise order in the sprites then it should work.

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