Announcement

Collapse

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

Collapse
X
  • 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){
    MovieClip.GotoAndStop(2);
    }

    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)
    Code:
    local MyPlayerController myPC;
    
    myPC = MyPlayerController(GetPC());
    if(myPC != none && myPC.myAI != none && myPC.myAI.IsInState('Idle'))
    {
        MovieClip.GotoAndStop(2);
    }

    Comment


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

      Comment


      • #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.

        Comment


        • #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...

          Comment


          • #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.

            Comment

            Working...
            X