Download

Paper 2D Flipbook (Sprite) - Material change at runtime

Hey there,
I am working on a project with Flipbooks and I intend to change certain “areas” of the sprite material at runtime. I struggle at naming the exact problem sadly, thus I try giving an example:

  • The player character is composed of sprites, animation handled through Flipbooks
  • The sprite shows a human with a suit (including different colors: skin, suit, details, pixel shading)
  • Upon picking up a power-up the suit gets a tint related to the power-up (lightning power-up -> slightly more yellow; fire power-up -> more red; and so on)

What I want to know is: is there any way to change the material color in the example without changing the entire sprite material and changing the color of the humans skin? (simply tinting it red would of course tint the entire sprite red right now)

Is there a way of composing a sprite of multiple single (sub-)sprites (one sprite for the suit, without the areas where the skin would show; one for the skin; and so on), each with their own material? Or is a keyframe in a flipbook able to have multiple sprites (for example a “suit”-sprite and a “skin”-sprite) somehow?

Can a material “know” what it is composed of when it is just 2D? I am thinking of a variation of the edge detection, but am not competent enough to come up with something.

I could just make a single Flipbook for each power-up, but I want to keep the needed sprites lower with both size and work amount in mind.

I am new to sprites in UE4 and this is probably an easy to tackle problem, so thanks in advance for taking the time to read this! :slight_smile: