The Infinity Blade Forums Have Moved

We've launched brand new Infinity Blade forums with improved features and revamped layout. We've also included a complete archive of the previous posts. Come check out the new Infinity Blade forums.
See more
See less

AI state in HUD

  • Filter
  • Time
  • Show
Clear All
new posts

  • 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){

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

    thanks in advance

  • #2
    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)
    local MyPlayerController myPC;
    myPC = MyPlayerController(GetPC());
    if(myPC != none && myPC.myAI != none && myPC.myAI.IsInState('Idle'))


    • #3
      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)

      BadC = BadGuyController(GetPC());

      if(BadC.IsInState('Chaseplayer') || BadC.IsInState('Attack')){
      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
        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
          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
            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.