How do I punch a hole in a sprite to reveal another in the same layer?

1 favourites
  • 6 posts
From the Asset Store
A simple fun and stylish endless scroller game ready to be customized and published.
  • The Intent

    I'm making an arcade first-person robot-shooty game. Several enemy robots can be on-screen at once, moving around or closer or further back from the camera during play. There's a mechanic where you can shoot a robot enough to break its armor and straight through to other targets behind it, so I'd like it to be visually possible to see other robots and objects *through* the bullet holes you're blasting into targets. Something like this mock-up image...

    The Problem

    I have "shothole" sprites that are pinned to robots when you shoot them, and they use destination out blend mode to cut out that bit of the robot sprite, revealing the background layer behind them. But all objects and robots exist in the same objects layer, so destination out will erase anything or anyone on this same layer behind whichever bot you shot. As seen in this pic of gameplay here...

    I've tried different combinations of blend modes on the shot holes and robots to no avail. Is there no way to mask out just a specific object on a layer instead of everything on it?

    Thank you to anyone reading this and offering ideas or help. I've been stuck on this for a long time and I hope I'm just missing an obvious answer I couldn't find on my own!

  • I know it doesn't answer your same layer problem, but why is it necessary that they are on the same layer?

    You will need to create a layering system where sprites that are behind others are moved onto a lower layer. The demo in this thread, specifically the 'reveal' actions are what I think you are looking for.

    construct.net/en/forum/construct-3/how-do-i-8/set-invisible-part-sprite-144516

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • I don't think it's possible to achieve with one layer and blend modes. What you can do is use a Drawing Canvas object as a mask. Paste the mask sprite onto the canvas, and then draw (cut) bullet holes in it.

  • calminthenight So the reasoning here is that I may have dozens or even potentially close to 100 objects - enemies included on-screen at once, and it seems really cumbersome to have to manually add 100 layers to the game between the background and HUD layers just in case I ever need that many and then also code a system that forcibly moves any objects or enemies that move closer/further than one another (which may happen frequently) to switch/re-order layers with each other on the fly such that there's still only one object per layer... I mean I had considered that as my absolute last resort up 'til now but it just felt like there had to be a cleaner way.

    dop2000 Apologies but I'm pretty new to the Drawing Canvas so I don't know that I've quite figured out what you're suggesting to do with it. I tried what I thought you meant:

    1. Drawing canvas above robot sprites (initially invisible so you only see ones in the canvas) with its drawing blend set to destination out

    2. "Paste object" both robots into the drawing canvas

    3. Drawing action like "Fill rectangle" to draw a hole in the canvas over the pasted drones

    But of course then I still end up with a hole that goes straight through both the front drone and the one behind it, just like before, so I'm probably misunderstanding... If it's not too much trouble, I've posted the small test project I tried this in here - could you give it a look and change it up to be like what you meant and post your version here?

    https://drive.google.com/file/d/1O3pcLIk9ccLlYluCQvc17-X1eWvHShyI/view?usp=sharing

  • I fixed your project:

    dropbox.com/s/iiri481a06u9otn/CanvasMaskTest.c3p

    Drag&drop droids, right-click to make a hole. Note, that Droid+Canvas objects are in a container. If you need to use multiple droid objects, you'll have to remove the container and link them with canvas instances by UID.

  • dop2000, you fantastic human being, this looks great! I should be able to integrate this solution into the main game and finally be free of this particular conundrum... Thank you!

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