Laying the groundwork for a Call of Duty style health feedback system

Warning: Drupal seems to hate tags and somehow adds < br />s to the code. Ignore these or see the UDK forum thread in the meanwhile

Remember the health feedback system (red coloured throbbing effect around the edges of the screen) that Call of Duty 4: MW and quite a few other shooters now a days use, and getting rid of the health bar in the process?
Well, I'm quite fond of that feature so let's lay the groundwork for building our own!

Index:

  • Content browser -Acquiring and prepping a material for our testing purposes
  • myHUD.uc -Creation, preparation, drawing materials.

Prerequisites:

  • Build environment
  • The UDK
  • Time;)

But I don't have a build environment!

Follow one of these awesome tuts (courtesy of their respecive owners):

What will I get?

  • A system wherein the UDK draws materials on screen based on the ammount of health the player currently has.

What will I not get by just using this tutorial?

  • Health regeneration
  • Fancy graphics
  • Auditory que

Will you update this post with additional information and or features?
Yes, I will probably update this post with future updates and features such as health regeneration and an auditory que based on the health 'state'. Feel free to contribute, I will add it to the post and credit you for it.

Go!

Content browser -Acquiring and prepping a material for our testing

  • Open the UDK Editor
  • Open the content browser
  • Find a file called "Eny_Effects.Beams.Materials.M_EFX_Beam_EnergyScroll_01" (or another 'animated' material).
  • Right click it and copy it by clicking on "Create a copy" (duh!), give it a package name (You will need to remember this!). I name it "Throb01" for this tutorial.
  • Erase the "Group" info and give it an easy name (Or hard, but you need to remember this).

    Be sure to enable "Save Packages" (I'm not 100% sure if it's really necessary but I got used to it due to kismet -bastard- screwing up my packages if I didn't enable it.)

  • It will have now created a new package for you, right click on it and save that in /UDK/UTGame/Content/YOURGAMENAME/UPK
  • All done in the editor, close it:)

myHUD.uc -Creation, preparation, drawing materials., the nitty gritty!

  • Open your programming environment of choice, I'm using Microsoft Visual Studio Shell 2008 with nFringe.
  • Create a uc script file and name it something you like, I'll be using "myHUD" in this tutorial.
  • Save it in /UDK/Development/Src/YOURGAMENAME/Classes/
  • Change the 'class' bit at the top of the document to:

  • This extends the UTHUD file

  • Add this line beneath it:

  • This defines the material we made in the content browser.

  • Add the following piece of code beneath it:




    See the comments (//) for details on what does what

  • Add the following to default properties:

  • The "myHUD" being our package in the content editor, and "throb01" the material in our package.

  • And you're done! Get a rocket launcher or something that can damage your health, fire a rocket on yourself and you will see that it will display the material above 60 health, and does not display it below 60 health.

But hey, the way the material is displayed looks nothing like COD4!

Yup, you'll need to do the following yourself

  • Move the location of the material and resize it (I would probably center it and enlarge it to fit the screen, then make the center of my material just white, transparent)





Overview of the total code: