HTWeapon: Part 2 – DrawWeaponCrosshair()
Important: I didn't notice this until after I posted this but my stuttering is pretty bad in this video. Just a heads up. I will re-do this in the future.
Video Version
Subject: HTWeapon: Part 2 – DrawWeaponCrosshair()
Skill Level: Beginner
Run-Time: 30 minutes
Author: Michael Allar
Notes: Going over how to have our weapons handle the drawing of our crosshair.
Written Version
Subject: HTWeapon: Part 2 – DrawWeaponCrosshair()
Skill Level: Beginner
Author: Michael Allar
Notes: Going over how to have our weapons handle the drawing of our crosshair.
Sorry about the indentation, it seems like my indentation will not survive copy paste… I will go back and fix the indentation later.
HTWeapon
The variables we added to HTWeapon
[csharp]/** HUD Stuff */
var Texture CrosshairImage;
var UIRoot.TextureCoordinates CrosshairCoordinates;[/csharp]
HTHUD
We've added a boolean bShowCrosshair to our declared variables.
[csharp]var bool bShowAmmo, bShowCrosshair;[/csharp]
Also reworked our DrawLivingHUD so that its a bit more streamlined and logic flows better. Also implements bShowCrosshair along with calling our DrawWeaponCrosshair() function.
[csharp]/**
* Anything drawn in this function will be displayed ONLY when the player is living.
*/
function DrawLivingHud()
{
local HTWeapon Weapon;
// Manage the weapon. NOTE: Vehicle weapons are managed by the vehicle
// since they are integrated in to the vehicle health bar
if( PawnOwner != none )
{
Weapon = HTWeapon(PawnOwner.Weapon);
if ( Weapon != none )
{
if ( bShowAmmo )
{
DisplayAmmo(Weapon);
}
if (bShowCrosshair)
{
Weapon.DrawWeaponCrosshair(self);
}
}
}
}[/csharp]
UDKGame Classes At This Point
Click here to download the source files I've had after completing this tutorial.