Forum Discussion

🚨 This forum is archived and read-only. To submit a forum post, please visit our new Developer Forum. 🚨
CHADALAK1's avatar
CHADALAK1
Explorer
12 years ago

PostRenderFor not working

Heey quick question,

I was curious if there was a bug in the PostRenderFor function in the Oculus build for UDK. for some reason it does not work :(.


class IronsightHUD extends UTGFxHudWrapper;

var int healthAmount;

var Vector ScreenPos;

var float position;

var ChadHUDTester HudMovie;

singular event Destroyed()
{
if(HudMovie != none)
{
HudMovie.Close(true);
HudMovie = none;
}
}


simulated function PostBeginPlay()
{
super.PostBeginPlay();

HudMovie = new class'ChadHUDTester';

HudMovie.SetTimingMode(TM_Real);
HudMovie.Init(LocalPlayer(PlayerOwner.Player));
}

event PostRender()
{
HudMovie.TickHUD();
}


DefaultProperties
{
bShowOverlays = true
}



class ChadBot extends UTPawn
placeable;

var HealthBarActor HBActor;

function AddDefaultInventory()
{
InvManager.CreateInventory(class'UTWeap_LinkGun');
}

event PostBeginPlay()
{
local Vector loc;
local Rotator rot;
super.PostBeginPlay();

AddDefaultInventory();

//this adds the empty actor to the custom socket on the Pawn----------------------------------------------------------
if(Mesh != none && Mesh.GetSocketByName('HealthBar') != none)
{
Mesh.GetSocketWorldLocationAndRotation('HealthBar', loc,rot);
HBActor = Spawn(class'HealthBarActor',,,loc,rot);

if(HBActor != none)
{
HBActor.SetBase(self,,Mesh,'HealthBar');
}
}
//----------------------------------------------------------------------------------------------------------------------

GetALocalPlayerController().myHUD.AddPostRenderedActor(self);

}

simulated event PostRenderFor(PlayerController PC, Canvas Canvas, Vector CameraPosition, Vector CameraDir)
{
local vector ScreenPosition;
local float HealthPercent;

super.PostRenderFor(PC,Canvas,CameraPosition,CameraDir);

// don't render it if it is not infront of the camera - it was not rendered for awhile
// or use the more precise method - CameraDir DOT (Location - PC.Location)
if(WorldInfo.TimeSeconds - LastRenderTime > 0.05)
{
return;
}

// you can offset the location with the height of the collision component
// if you want it above the actor
ScreenPosition = Canvas.Project(HBActor.Location);

// drawing healthbar fg red
HealthPercent = float(Health)/ float(HealthMax);
Canvas.SetPos(ScreenPosition.X ,ScreenPosition.Y);
Canvas.DrawRect(HealthPercent,6);
}

function bool Died(Controller Killer, class<DamageType> DamageType, vector HitLocation)
{
Super.Died(Killer, DamageType, HitLocation);
GetALocalPlayerController().myHUD.RemovePostRenderedActor(self);
}


DefaultProperties
{

Begin Object Name=CollisionCylinder
CollisionHeight=+44.000000
End Object

Begin Object Class=SkeletalMeshComponent Name=SandboxPawnSkeletalMesh
SkeletalMesh=SkeletalMesh'CH_IronGuard_Male.Mesh.SK_CH_IronGuard_MaleA'
AnimSets(0)=AnimSet'CH_AnimHuman.Anims.K_AnimHuman_BaseMale'
AnimTreeTemplate=AnimTree'CH_AnimHuman_Tree.AT_CH_Human'
HiddenGame=FALSE
HiddenEditor=FALSE
End Object

Mesh=SandboxPawnSkeletalMesh


Components.Add(SandboxPawnSkeletalMesh)

bJumpCapable=false
bCanJump=false
bPostRenderIfNotVisible = true

GroundSpeed=500
}