How do I Clearing Tilemap Tiles Overlapping a Sprite?

0 favourites
  • 3 posts
From the Asset Store
Basics sprites and tilesets to build a platformer game or prototype
  • Hello everyone,

    I hope you're all doing well. I am currently working on a project in Construct 3, and I've encountered a problem that I can't seem to solve on my own. I have a tilemap object in my layout that acts as a solid platform, and I have also placed a sprite called "hole" in certain areas. My goal is to have all the tiles in the tilemap that overlap the "hole" sprite to be cleared or removed when the layout starts.

    I have tried a few approaches, but none of them have worked as expected. I am reaching out to this amazing community to see if anyone has experience with this issue or can suggest a solution.

    I believe there might be a way to accomplish this using events or functions, but I'm relatively new to Construct 3, so I might be missing something obvious.

    If anyone has encountered a similar problem or has any insights on how to achieve the desired effect, I would be immensely grateful for your help. Perhaps there's a specific plugin or extension that could make this task easier?

    Thank you in advance for any assistance you can provide. I really appreciate your time and expertise!

    Thank you all

  • Basically you’ll want to loop over all the tiles, aka consider each tile one by one and remove it if it’s overlapping the sprite.

    However you can only check for an overlap with the entire tilemap and not one tile. One solution is to check if the center of a tile is overlapping the sprite, another idea is to position a tile sized sprite at the tile to use a collision detector.

    Also you only need to check the tiles that overlap the sprites bounding box.

    Event would roughly be this. It assumes the tilemap is at 0,0 and has a tile size of 32x32

    For x from int(sprite.bboxleft/32), int(sprite.bboxRight/32+1)

    For y from int(sprite.bboxtop/32), int(sprite.bboxbottom/32+1)

    Tilemap at x,y <> -1

    System: point (x*32+16, y*32+16) overlaps sprite

    — tilemap: remove tile at x,y

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Hi everyone!

    I wanted to share with you the solution to the problem that has been bothering me for days, and I have to sincerely thank user R0J0hound for his precious insight! I've attached a screenshot of the resolution below, hope it helps someone else who is in the same situation.

    Luckily, R0J0hound provided a tip that set me on the right track. I followed the steps he kindly advised, and lo and behold the problem was successfully resolved!

    Communities like these demonstrate the power of collaboration and mutual aid. Thanks again to R0J0hound for kindness to share his knowledge!

    If anyone has any questions about my experience or solving the problem, I'll be happy to help. Together we can overcome any obstacle!

    Thank you all!

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