Hitmask for Characters Wound

Hello friends.

Does anyone know about some tutorial on how to use Hitmask for creating decal effects on the body of the character (blood wound) after the character is shot?

I only found these 2 small tutorials on UDN, however they are too much vague for a beginner in Unreal Script, I could not implement the hitmask feature:


Could anyone help me, please?


I remember struggling with this very issue in my early days of Unrealscript learning too, as alot of the UDN pages assume a certain level of scripting knowledge (and the weird, half-finished sentences and broken English certainly don’t help).
First of all, you’ll want to create global variables of the HitMaskComponent and a TextureRender2D, so you can reference them later in your code:

var() const SceneCapture2DHitMaskComponent HitMaskComponent;
var TextureRenderTarget2D MaskTexture;

Then create the actual Hitmaskcomponent in your default properties:

// Add hit mask to the actor
      Begin Object Class=SceneCapture2DHitMaskComponent Name=HitMaskComp
      FadingStartTimeSinceHit = 9.0
      FadingIntervalTime = 0.35
      FadingDurationTime = 8.0
      FadingPercentage = 0.96
      End Object

Then, ideally in a function that is called when the pawn spawns ( I put this in SetCharacterClassFromInfo() ), you need to create the texture target we made a global variable for, which the Hitmask will use when drawing, and feed that into the Hitmaskcomponent so it knows exactly how to draw the Hitmask texture:

// Create Mask Texture of 64x64(or whatever size you'd like)
      MaskTexture = class'TextureRenderTarget2D'.static.Create(64, 64, PF_G8, MakeLinearColor(0, 0, 0, 1));

      if ( MaskTexture!=none )
            // Update HitMaskComponent with this texture
            HitMaskComponent.SetCaptureTargetTexture( MaskTexture );

As for the material itself, create the appropriate nodes as explained on the UDN page. Then create a ‘Lerp’ Node, and plug the ‘FilterMask’ Node into the ‘Alpha’ input. Plug your base texture into the ‘A’ input, and whatever gore texture you want to be ‘revealed’ by the Hitmask into ‘B’ input. This is the main advantage of Hitmasks over decals - you could, for example, create a Terminator-style enemy that has a circuitry/metallic skeleton texture as the ‘B’ input and have that be exposed by the Hitmask whenever you damage it.
Next, you need to create a MaterialInstanceConstant for your base material, and feed the Filtermask parameter the MaskTexture info:

local MaterialInstanceConstant MIC;
MIC = Mesh.CreateAndSetMaterialInstanceConstant(0); // material you'd like to replace
      if ( MIC != none &&  MaskTexture!=none )
            // Set new texture as FilterMask parameter
            MIC.SetTextureParameterValue('FilterMask', MaskTexture);

Once this has all been set up, you just need to call the code which actually creates the Hitmask, in TakeDamage or wherever is most appropriate for you:

HitMaskComponent.SetCaptureParameters(HitLocation, 20.f, HitLocation, FALSE);

It’s worth noting that the quality of the resulting hitmask is largely dependent on how well you have set up your character’s UVs; if you’re just using a basic prototype material for your characters then the hitmask will look very ugly or not work at all. In that case, it would be better to simply apply a blood decal.

Thanks brother for the usefull informations and your willing to help me. I will for sure try all this. Trully thanks.

Sorry, I think I need to get the basics of Unreal Scripting before trying more complex effects, but just for the sake of playing with UDK, i would like to try a fast setup to simulate enemies wound.

But you said “it would be better to simply apply a blood decal”. You mean is possible to spawn decals over the character material when you shoot the enemy (pawn). If so, how can I do this?

Other thing I thought, would be possible in example to just change the character texture (like default texture by wounded texture) whenever the pawn dies. Althought it would not look too much realistic, however it would be cool. I am creating a shooter game, with non stop action, like Contra (Supernes), with frenetic action, too much shooting and enemies on screen, so I assume the player would not have too much time to pay attention to these small details, because this, at least for my game, just showing another texture on the character as soon as he dies would be enough, so the player kills the enemy, and if he goes there to look at the enemy corpse, he will see the enemy all wounded (wounded texture).

How can I change the character texture as soon as the pawn dies?


At least in my version of UDK (2014-08), you can apply decals to pawns like this:

WorldInfo.MyDecalManager.SpawnDecal( YourDecal,  HitLocation, Rotation, 22, 22,DecalThickness,false,,PawnMesh,true, true, bonename);

The PawnMesh(Mesh decal is being drawn on) and bonename (closest bone to where decal is being spawned) are important; I don’t think it will work on skeletal meshes without them. As for simply changing the pawn’s entire material upon death, you could use the MaterialInstanceConstant method as explained above, only this time you will be changing the value of a ScalarParameter. You would have to make the MIC variable a global one, as opposed to a local variable in the example I provided, so you can access it anywhere in the code. Then in the material editor, create a setup similar to the one above, with a Lerp node taking in the ‘base’ texture in A, and the ‘gore’ texture in B, only this time for the Alpha, you will be plugging in a ‘ScalarParameter’ node. This ScalarParameter node determines the influence of B over A, so you could have the character get progressively bloodier as they take more damage. Put an appropriate name into the Paramater Name field. You can control the influence of the node like this:


You could also simply do a SetMaterial call which swaps the entire material out, though this is more memory-heavy (or so I’ve heard), and you have less control over it:

Mesh.SetMaterial(ElementIndex, Material)

Thanks mate! I will try to spawn decals on my pawn.

So this code:

WorldInfo.MyDecalManager.SpawnDecal( YourDecal, HitLocation, Rotation, 22, 22,DecalThickness,false,PawnMesh,true, true, bonename);

I place it inside my pawn (enemy character) right?

About the bone names, I am using the default UT3 Skeleton (with 70 bones and using the default bones names, and using the default UT3 Sockets bones.

This is my pawn code for enemies. Could you please tell me exactly where do I put the code for spawn decal?:

//this pawn class is for setting up a basic NPC (enemies) system

class LocustGrunt extends UTPawn


var SkeletalMesh defaultMesh;
var MaterialInterface defaultMaterial0;
var AnimTree defaultAnimTree;
var array<AnimSet> defaultAnimSet;
var AnimNodeSequence defaultAnimSeq;
var PhysicsAsset defaultPhysicsAsset;

//add custom taunt and voice class to pawn
var class<UTVoice> VoiceClass;

static function class<UTVoice> GetVoiceClass()
	return Default.VoiceClass;

//override to do nothing
simulated function SetCharacterClassFromInfo(class<UTFamilyInfo> Info)

simulated event PostBeginPlay()

  Begin Object Name=WPawnSkeletalMeshComponent
  End Object


//add custom taunt and voice class to pawn


You would put it in TakeDamage, ideally. Look at the TakeDamage function code in UTPawn to see how it works, especially the HitInfo. Looking at the base classes and figuring out how the experts do it is a common way of learning UnrealScript. I’d also highly recommend Mougli’s scripting tutorials found here, as he describes alot of the basic functionality of UDK:http://www.moug-portfolio.info/category/tutorials/

Got it :cool:

I was able to make blood particle spawn from the enemy when shot, just want to make his body show some wounds


Im going to have to sit down and spend some time with this but its unlikely ill get anywhere.

Closest thing i can provide is an exploding barrel that spawns a decal at the hitlocation, but that info is probably loosely contained with all of the above posts.

Have you looked here:?

Links are still active

this stuff is not great for overhead on consoles

Thanks man for the link, this is exactly what I was looking for, a step by step tutorial! The only problem is the screenshots of the material setup are offline. Is there anywhere I can find these screenshots?


  • i archive everything. Download the attachment and rename the file…

from:UDK HitMasks.TXT
to:UDK HitMasks.docx

*If a docx is an issue let me know. It should have kept the original dimensions of the image so you can export back to original size or re-size etc

and for future reference- when you find something your interested,like this thread for example, copy and paste all of it and save it as a word doc somewhere- someone, someday may want it

Thanks my dear brother, I got it. The materials are saved inside the Hitmask Example Map, and it’s working perfectly!!! I will just change the blood texture to look more realistic. But thanks bro for giving me the link to this awesome tutorial. Trully the guy who made this tutorial is a trully gentleman and he was able to summarize into just few lines and made hitmask so easy to implement!!! It’s a shame that EPIC did not gave so concise tutorial like this.


Was there anything wrong with what I provided? I basically walked you through the entire process.

Hello my brother, thanks, sure thanks for your help, it was of a great value. However, as I am a begginner on Unreal Script (I have good experience on level design), so then I found easier to me get something ready and modify to my needs.

So this tutorial:

Was perfectly for me, a total noob on programming, so before anything, before digging up on programming the classes, i just installed that guy`s map on UDK, and opened it. It worked, so then I began to dissecate the example, the code, the class, the material, untill I have done on my behalf.

So here is it, blood wound on enemies body:

Anyway, thanks for everyone who helped me here, all help from anyone is of great value for me.


Looks sweet, with the exception of the weird lighting :slight_smile: wish you could help port the old unreal content with me. I know you say it is easy, but if you check my videos you will see i’ve had issues with the conversions in the past(XCom soldier looks a bit weird, chainsaw and minelayer weapon lacks full animations, etc).
#I really should install UT3 and do something.

also, how goes progress?