1
\$\begingroup\$

I'm working on a 2D Sidescroller and I'm wanting to achieve a object that when activated it creates a port-hole to the sprites underneath, giving the appearance of the object "cleansing" the area.

Edited image showing desired effect

Edited image showing the desired effect

At this point I have no idea how to achieve this and am after suggestions, thanks!

\$\endgroup\$
1
\$\begingroup\$

Several options here.

If your "cleansing area" thing is "just" a color swap, you can do that using a custom shader that will take original pixel colors and swap them with a given palette. Then it'll change purple pixels to light green, dark blue to light blue...

If color swapping is not what you're looking for and you have actually two versions of the same level (one dark, one clean), you have to have the both version in your actual game scene. Using two cameras, one for dark and one for light. The light camera will render into a render texture instead of the screen. With that render texture you'll be able to only display part of it. Using a custom shader you'll be able to show what's around the player or any part you want.

|improve this answer|||||
\$\endgroup\$
0
\$\begingroup\$

I would use a sprite mask for this, maybe several depending on exactly what you want to do. You would need multiple sprites, for example, a "dirty" trashcan and a "clean" trashcan both at the same position but they respond to the mask differently. The "dirty" sprite would be visible outside the mask, and the "clean" sprite visible inside the mask.

https://docs.unity3d.com/Manual/class-SpriteMask.html

This sounds like a really cool idea, I hope it works out well for you.

|improve this answer|||||
\$\endgroup\$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.