How do I properly work with overlaps ?

0 favourites
  • 3 posts
  • Hi Constructors,

    I'm facing a dumb issue. The main features of my game-wanna-be prototype are done and so far, running well. For various reasons, the player can sometimes go through the walls or the floor of the environment, for a limited amount of time.

    Once the said amount of time has passed, walls and floor become solid again. Classic, right ? Now, if the player is still IN a wall or in the floor at this precise moment, he's obviously supposed to be crushed and killed.

    I thought I could easily deal with this. Boy, I was wrong.

    I check if any of the walls/grounds objects of my family is overlapping my player. If they do, and if they have the same collisionGroup, the player must be destroyed. Seems coherent to me, but in the preview, my player is killed as soon as he collides with the floor or the wall. This was not intended.

    I've tried using an offset (checking if my family is overlapping my player's origin) but it was another failure. Why does this event acts like a simple "on collision with" ? Where is my loophole ?

    I apologize if this questions has already been treated. There are around 168 pages talking about Overlaps issues, yet I didn't find one that suits my needs. Might be a mistake from my part, tho.

  • I think you need to move this code (as a sub-event) to the event where you make the walls solid. So something like this:

    On timer "MakeWallsSolidAgain"
    ...Player is overlapping Walls -> Player destroy
    ...Else -> Wall sets solid enabled
    

    The problem is, player may still be considered as overlapping if it's touching the wall. So instead of "is overlapping" you can use another condition - "System pick Walls by overlapping point (player.X, Player.Y)". It will only be triggered if the origin image point of the player sprite is inside the wall.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Thank you for your clear and quick answer, dop2000 . It works like a charm ! Have a nice day

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