Announcement

Collapse
No announcement yet.

Scaleform HUD using swf won't load to game

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    Scaleform HUD using swf won't load to game

    hi, I'm currently learning how to replace the game HUD with my own custom HUD using flash scaleform.

    here's MyGameInfo.uc :
    Code:
    class MyGameInfo extends UTGame;
    
    DefaultProperties
    {
        PlayerControllerClass=class'PT3rdPersonController'
        DefaultPawnClass=class'PT3rdPersonView'
        HUDType=class'PTGameHUD'
        bUseClassicHUD=true
        
        bScoreDeaths=false;
    }
    Here's my PTGameHUD.uc :

    Code:
    class PTGameHUDextends UTHUDBase;
    
    /*reference to the swf file*/
    var PTSTGFxHUD HUDMovie;
    
    singular event Destroyed()
    {
        if (HUDMovie != none)
        {
            HUDMovie.Close(true);
            HUDMovie = none;
        }
        Destroy();
    }
    
    simulated function PostBeginPlay()
    {
        super.PostBeginPlay();
        
        `log("initiating HUDmovie !!");
        
        HUDMovie = new class'PTSTGFxHUD';
        HUDMovie.SetTimingMode(TM_Real);
        HUDMovie.Init();
    }
    
    event PostRender()
    {
        HUDMovie.TickHUD();
    }
    and here's my PTSTGFxHUD.uc :

    Code:
    class PTSTGFxHUD extends GFxMoviePlayer;
    
    var float LastHealth, MaxHealthBarWidth;
    
    var GFxObject HealthBarMC, HealthPercent, Crosshair;
    
    function int RoundNum(float num)
    {
        local int iNum;
        local float fNum;
        
        fNum = num;
        iNum = int(fNum);
        fNum -= iNum;
        
        if (fNum >= 0.5f) return iNum+1;
        else return iNum;
    }
    
    function int GetPercentage(int val, int max)
    {
        return RoundNum(float(val) / float(max) * 100.0f);
    }
    
    function Init(optional LocalPlayer LP)
    {
        Start();
        Advance(0.f);
        
        LastHealth = -1337;
        
        HealthBarMC = GetVariableObject("_root").GetObject("HealthBar");
        MaxHealthBarWidth = HealthBarMC.GetFloat("_width");
        Crosshair = GetVariableObject("_root").GetObject("Crosshair");
        
        `log("HUD:"@HealthBarMC@Crosshair@MaxHealthBarWidth);
    }
    
    function TickHUD()
    {
        local PT3rdPersonController PC;
        local PT3rdPersonView ThePawn;
        
        PC = PT3rdPersonController(GetPC());
        ThePawn = PT3rdPersonView(PC.Pawn);
        
        if (ThePawn == none) 
        {
            `log("no pawn found !!");
            return;
        }
        
        `log("pawn found!!");
        
        if (LastHealth != GetPercentage(ThePawn.Health, ThePawn.HealthMax))
        {
            LastHealth = GetPercentage(ThePawn.Health, ThePawn.HealthMax);
            HealthBarMC.SetFloat("_width", LastHealth/100.0f * MaxHealthBarWidth);
        }
    }
    
    defaultproperties
    {
        bAutoPlay=true
        bDisplayWithHudOff=false
        MovieInfo=SwfMovie'ProtoTrainerUI.Sample_GameHUD.PT_Sample_GameHUD'
    }
    when I compiled it, no errors at all. But, when I changed the WorldInfo to MyGameInfo and play in editor, the HUD won't show up.

    When I remove these lines :
    Code:
        PlayerControllerClass=class'PT3rdPersonController'
        DefaultPawnClass=class'PT3rdPersonView'
    , The HUD shows....

    I'm stuck here and I can't move anywhere without solving this problem. THX before for any help

    #2
    sorry, it's solved now. I forgot that I had another HUD placed in my ControllerClass that replaced the HUD I made in flash

    solved now....

    Comment

    Working...
    X