Sure, here is the PostRenderFor:
Code:
simulated event PostRenderFor(PlayerController PC, Canvas Canvas, vector CameraPosition, vector CameraDir)
{
local Vector lPosition, lTextSize;
local Font previous_font;
local float lHealthSize;
local float lBackgroundOffset;
local SkeletalMeshSocket socket;
if (Health <= 0)
return ; // no display for the dead.
//We store the font and restore it at the end, otherwise it will mess up the drawing of the rest of the HUD.
previous_font = Canvas.Font;
Canvas.Font = class'Engine'.Static.GetMediumFont();
socket = Mesh.GetSocketByName('S_Hud');
if (socket != none)
{
lPosition = Mesh.GetBoneLocation(socket.BoneName);
}
else
{ // if there is no socket, put it above the eyes.
lPosition = Location;
lPosition.Z = lPosition.Z+EyeHeight;
}
lPosition = Canvas.Project(lPosition);
Canvas.TextSize(Name, lTextSize.X, lTextSize.Y);
// actor name
Canvas.SetPos(lPosition.X - lTextSize.X/2,lPosition.Y);
// Canvas.SetDrawColor(255,128,128,255);
Canvas.DrawText(Name,true);
if (mIsFocused)
{
lBackgroundOffset = 18;
}
else
{
lBackgroundOffset = 0;
}
lPosition.Y = lPosition.Y - 20;
// This is the healthbar background
Canvas.SetPos(lPosition.X - 45,lPosition.Y - lBackgroundOffset);
Canvas.DrawTile(HudIcons, 91, 18+lBackgroundOffset, 16, 19-lBackgroundOffset, 91,18+lBackgroundOffset);
// actual healthbar
lHealthSize=91*Health/HealthMax;
Canvas.SetPos(lPosition.X - 45,lPosition.Y);
Canvas.DrawTile(HudIcons, lHealthSize, 18, 16, 40, lHealthSize, 18);
Canvas.Font = previous_font;
}
and as suggested in the link above, the AddPostRenderedActor is called here:
Code:
auto state InitializingState
{
function bool AttachHud()
{
local PlayerController lAPlayerController;
lAPlayerController = GetALocalPlayerController();
if (lAPlayerController != none)
{
lAPlayerController.myHUD.AddPostRenderedActor(self);
return true;
}
return false; // didn't work, need to try again
}
Begin:
if (AttachHud())
{
GotoState('InitializedState');
}
goto 'Begin';
}
state InitializedState
{}
Bookmarks