Results 1 to 6 of 6

Thread: AI state in HUD

  1. #1
    cHamster
    Guest

    AI state in HUD

    I have a quick question on referring to AI's state inside my HUD class. The HUD suppose to update each time my AI controller enters a new state. But i have no idea how to refer back to those state in my HUD. Here is the pseudocode for what i want to do:

    if( AI state == Idle){
    MovieClip.GotoAndStop(2);
    }

    can somebody show me how to compare AI state in HUD class? I kept getting syntax error.

    thanks in advance

  2. #2
    Omar007
    Guest
    You'll have to have a reference to your AI somewhere. Then you can do this for instance (reference is in my PlayerController in this case)
    Code:
    local MyPlayerController myPC;
    
    myPC = MyPlayerController(GetPC());
    if(myPC != none && myPC.myAI != none && myPC.myAI.IsInState('Idle'))
    {
        MovieClip.GotoAndStop(2);
    }

  3. #3
    cHamster
    Guest
    is it necessary to have my AI in my player controller class just like you? currently this is what i have:
    local MyPawn MyP;
    local BadGuyController BadC;

    MyP = MyPawn(PlayerOwner.Pawn);
    if (MyP == None)
    {
    return;
    }

    BadC = BadGuyController(GetPC());

    if(BadC.IsInState('Chaseplayer') || BadC.IsInState('Attack')){
    StatusTF.GotoAndStopI(2);
    StatusMC.GotoAndStopI(2);
    HealthBarMC.GotoAndStopI(26);
    }
    it returns me this error: Error, Cast from 'PlayerController' to 'BadGuyController' will always fail

    is there another way to write it if my ai controller and my pawn controller are 2 seperate classes? please advice...

  4. #4
    Omar007
    Guest
    That isn't even possible. GetPC() returns the PlayerController of the player owning the HUD.

    For that error, it means that BadGuyController is not extending PlayerController. Therefore BadGuyController can never cast a PlayerController.

  5. #5
    cHamster
    Guest
    if GetPC() is used for referencing PlayerController, then can you suggest a way to reference AIController?

    can you give me an example on referencing AI in HUD? i think i understand how to reference PlayerController in HUD now, just not AIController...

  6. #6
    Omar007
    Guest
    I'm not 100% sure on what you are trying to do but I assume you want the player to know something about the state of an AI in the game?
    If so, I assume, you create (spawn) the AI somewhere in your code. Store a reference to this AI in you player controller. You'll need to have a variable in your player controller class in which the reference will be stored.
    Then you can use code similar to what I gave before.

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •