Announcement

Collapse
No announcement yet.

Possess player pawn with AIController for task?

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

    Possess player pawn with AIController for task?

    Hi!

    I've got a question and am looking for some advice from anybody that may know. I've got a character that the player controls (Like the top down template...Click and the player pawn goes somewhere). Now I want the player to do gather a resource (chop a tree down). The way I'm doing this now is:

    When the player right clicks a tree, I have my gather resource move the character to itself (with a looping timer), then he does an animation, and after he's done he goes somewhere else to drop the resource off. None of this is being done with a behavior tree or AI of any kind. For some reason this seems a little hack-ey to me (although maybe that's normally what you'd do?).

    Later in the game (as my game develops) I will have NPC's that does this action on their own (with a behavior tree and what not). Here's what I'm wondering. I can set all this behavior up with AI in a behavior tree (moving to a resource, playing an animation for a set amount of time, then moving to another location). To me it seems easier to move the player pawn with a behavior tree. Should I just have an AIController possess my main character pawn and do this behavior instead of me manually having the gather resource communicate with the player pawn and then the player pawn communicating with a storage type building, etc...?

    Basically my question is not how to do it, but just whether or not (if you were doing this), if you'd use an AIController or not (I think that's possible on a player pawn). I'm not sure if one way is generally better than the other, or if it really doesn't matter. Thanks for any advice everyone!

    #2
    I have similar setup like this.

    I made BP_Keyboard_AI ai controller. All it does is moving to point i set from real player controller.
    And I do not control traditional player pawn (in my setup it is only camera that snaps to pawn possessed by Keyboard_AI, or any actor that i feed it with pointer).

    So my keyboard AI directly translates input axis vectors into direction I want to move my AI pawn. Then it adds world location of that pawn and result is desired world location where I want AI to move that pawn. Distance of 200-300 units from pawn in direction i want to move is fine.

    Just remember to create navmesh, else AI wont move pawn.

    Comment


      #3
      Oh interesting, okay great. Thank you! If anybody else has any interesting ways of doing this I'd be interested to hear. Thanks!

      Comment

      Working...
      X