Announcement

Collapse
No announcement yet.

NPC Root Motion with Behavior Trees

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

    NPC Root Motion with Behavior Trees

    Howdy,

    I've been struggling to get my NPC to move to its target point. I'm using root motion animations, and because of that the MoveTo node in the behavior tree seems to not be the right choice because it can't use the movement settings from the character, as Root Motion has it's own velocity and so forth. What happens is the NPC basically walks in one place.

    I've look throught the forum and answer hub with partial answers, but not enough to put it all together. Sadly, every tutorial on YouTube seems to discuss root motion for player controlled characters.

    How does one accomplish this?

    Cheers,

    Sterling
    Run with the flock, end up a lamb chop!

    Unreal 4 in 30 Days - An Unreal Experience: https://youtu.be/DV5l7d4b9Cs

    #2
    Make your own BT Nodes.

    Extend the BTTask_BlueprintBase in Blueprint or C++ UBTTaskNode.

    Comment


      #3
      Originally posted by SterlingY View Post
      Howdy,

      I've been struggling to get my NPC to move to its target point. I'm using root motion animations, and because of that the MoveTo node in the behavior tree seems to not be the right choice because it can't use the movement settings from the character, as Root Motion has it's own velocity and so forth. What happens is the NPC basically walks in one place.

      I've look throught the forum and answer hub with partial answers, but not enough to put it all together. Sadly, every tutorial on YouTube seems to discuss root motion for player controlled characters.

      How does one accomplish this?

      Cheers,

      Sterling
      I don't have the answer for you yet however I'm just about to start trying to solve this for my own project as well so will keep an eye on this thread and share any progress/ideas with you if you'd like.

      I think it depends on how you've got your root motion and bland spaces set up. At the moment I'm using a 8 way strafing blend space setup so I just need to direction and an arbitrary speed value to determine if the character is walking or running

      My plan at this stage is to:

      1. Forget about the MoveTo node altogether. My behavior tree will simply return a target location to the controller
      2. The controller will calculate direction of the target location based on the direction to character is facing and will then pass this direction to the animation blue print, along with either a 0.5 or 1 value to determine if I want the character to walk or run to toward the target.
      3. Either the controller of the BT will keep track of how close the character is to the target and lerp the speed down to 0 once the character has reached the target. The character probably won't be spot-on target but it should be pretty close.

      No idea if this will work but I'm about to get it a try

      Comment


        #4
        Originally posted by mrpdean View Post
        My plan at this stage is to:

        1. Forget about the MoveTo node altogether. My behavior tree will simply return a target location to the controller
        2. The controller will calculate direction of the target location based on the direction to character is facing and will then pass this direction to the animation blue print, along with either a 0.5 or 1 value to determine if I want the character to walk or run to toward the target.
        3. Either the controller of the BT will keep track of how close the character is to the target and lerp the speed down to 0 once the character has reached the target. The character probably won't be spot-on target but it should be pretty close.

        No idea if this will work but I'm about to get it a try
        I would definitely like to find out about how you come to a solution, assuming you do. I did solve my walking in place problem. Major human error there. It turns out I did not export my animations with root motion. That is fixed, but the rest of it is still a thing of wonder. I had been thinking of something similar to what you outlined, but since I had issues with the BT, I decided to try and skip it, at least at first, so I tried to set it all up in the AnimBP, and I used a "Find Path to Location Synchronously," but still running into problems.

        I think my biggest problem will be determining varying degrees of rotation for turning left or right. How to tell the blendspace that the character should make a sharper turn (135 degree anim cycle) instead of a wide arc (45 degree anim cycle).

        Anyway, keep me/thread posted on your progress.

        Cheers,

        Sterling
        Run with the flock, end up a lamb chop!

        Unreal 4 in 30 Days - An Unreal Experience: https://youtu.be/DV5l7d4b9Cs

        Comment


          #5
          Currently having this issue. mrpdean SterlingY Did you ever solve this?

          Comment

          Working...
          X