PDA

View Full Version : Possible to correctly use a UTHUD object?



ysage89
10-23-2008, 01:12 AM
I am currently making tunnel vision, which works fine but I wish to change it based upon the player's health. I got the logic down and the code down for everything, but I just cannot seem to make the object work with the functions inside the new class for the HUD.

I named the new class for HUD...


class NewHUD extends UTHUD;

and inside I changed a few variables that work. I also added a function inside....


function ChangeHitEffect(float Fade, float Intensity)
{
HitEffectFadeTime=Fade;
HitEffectIntensity=Intensity;
}


Now in the pawn function, I am creating an object to use that function so I can change the fade and intensity...


local NewHUD Tunnel;



However, the compiler said (I knew this would happen, I just don't know how to declare it something) that Tunnel is unused before given a value.

What can I make Tunnel equal to...? And how? I don't know the Unreal script syntax completely yet.

Thanks.

Xyx
10-23-2008, 04:51 AM
The HUD is an Actor, so it can simply be Spawn()-ed.

I suspect you have to create a custom PlayerController (http://www.codekisk.com/unreal/ut3/scriptref/engine/playercontroller.html) and override its SpawnDefaultHUD (http://www.codekisk.com/unreal/ut3/scriptref/Source_engine/playercontroller.html#750) method to spawn a NewHUD instead of a regular HUD.

Or perhaps even better... write a mutator that replaces HUD objects with NewHUD objects.

Kirk
10-23-2008, 08:32 AM
I think you can do this in the HUD only, without changing Pawn, and just change the HUD type which is spawned, like Xyx said. You should be able to access any information you need from within the HUD (it has all sorts of things on Health) or from the PawnOwner.

Pr0eX
10-23-2008, 12:31 PM
If its a TC then just tell your gametype to use your new HUD as the default HUD:



defaultproperties
{
HUDType = class'MYHUD'
}


if its just a mutator then you need to replace the HUD (myHUD) from the PlayerController class. (maybe by using the "Mutate"-function).
(Be aware of this method, there could be problems if you use the mutator with some modified games!)