How do I make characters block each other without solid behavior?

0 favourites
  • 6 posts
From the Asset Store
Place blocks on a board, join them together to form even bigger blocks!
  • I'm trying to make a game that features one-on-one fighting, and I'd like to make it so the characters can't physically pass through each other, yet don't have the solid behavior (so they can't use each other as platforms), kind of how characters can 'push' each other in Street Fighter and other 2D fighters. I tried making the characters into physics objects, but because the characters are different heights, I initially coded it so that the height of the invisible collision box changes to match the character being used. This resulted in weird behavior with the characters constantly jumping a pixel or two off the floor.

    I hope I'm being clear enough. Any help or advice would be appreciated.

  • For your collision box, add an additional 1 px collision box at the base of it. If this one overlaps the normal one (someone is standing on top of someone else), it pushes one or both rapidly off to a side until it is no longer overlapping.

    If you don't want to use two separate boxes, you can also use is overlapping at offset condition to check below.

    game.capcom.com/cfn/sfv/column/131422

  • For your collision box, add an additional 1 px collision box at the base of it. If this one overlaps the normal one (someone is standing on top of someone else), it pushes one or both rapidly off to a side until it is no longer overlapping.

    If you don't want to use two separate boxes, you can also use is overlapping at offset condition to check below.

    https://game.capcom.com/cfn/sfv/column/131422?lang=en

    Thanks, that article gave me something to think about. I think you've led me to a functional solution for now using overlapping with offset. But I would like you to clarify what you mean by "add an additional 1 px collision box at the base of it". Would that be a single pixel or something at, say a pixel wider than the collision box? Would that be a solid box?

  • No, it should not be solid and be exactly the same width as the main, solid collision box.

    If it is wider, then you'll run into collisions when approaching from the side. If it is narrower, then the main collision box has a tiny section it can get stuck on from above.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Ah, so I should make the players' collision boxes solid, and overlap them with a non-solid box that would be used to trigger the actual collisions and push the players away. That sounds clever...I'm going to experiment with that.

    Thanks.

  • Alternatively you could use the solid behaviour and compare player 1 height to player 2. If one is higher and jumping you can set solid disabled on the other to avoid the other player platform issue. Once the jumping player has landed if their X positions are overlapping you can move both players away from each other.

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