Announcement

Collapse
No announcement yet.

Get NPC to stop walking and face (/interact with) the player?

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

    Get NPC to stop walking and face (/interact with) the player?

    Hi everyone,

    i've been struggling with my NPCs for a while now, many tutorials on youtube seem to be a bit out of date and i can't find a precise answer to my problem.

    there it is:

    - I have an NPC that walks from point A to point B
    - I want to make him stop and look at me when i press the action button
    - i want to open a dialogue widget (optional for the moment)
    - i want him to continue his path once the player goes away.

    Here are my first attempts:

    **Attempt 1:**

    Click image for larger version

Name:	Prob 1.png
Views:	1
Size:	164.6 KB
ID:	1189109


    Click image for larger version

Name:	Prob 2.png
Views:	1
Size:	132.0 KB
ID:	1189110


    This one simply did not work, the "InputAction Action" node does not activate.

    i tried linking a branch after the "Move To Point" Node with the condition "player Nearby" attached to it, but it did nothing regarding the branchng of false and true)


    **Attempt 2:**

    Click image for larger version

Name:	partie 1.png
Views:	1
Size:	140.9 KB
ID:	1189111

    Click image for larger version

Name:	partie 2.png
Views:	1
Size:	138.1 KB
ID:	1189112

    Click image for larger version

Name:	partie 3.png
Views:	1
Size:	119.1 KB
ID:	1189113

    my goal on this one was to make the character continue his path after i interrupted him, which worked, the problem was the "Move To Point" Nodes were still executing while the player was still next to it, the NPC kept trying to move to the points.but seemed to be switching between moving and stopping.

    *additionnal Informations:

    - I'm Using 4.11
    - I did not use the Level blueprint, to prevent potential conflicts (as heard on many tutorials)
    - I'm using the Third Person template
    - Interaction input works with the Dialogue NPC i set up earlier.

    There it is, now i'll gladly give more informations, and i hope resolving this could help other developpers that potentially encountered the same problem.

    Thanks in advance!

    PS: AnswerHub kepps telling me to verify the section in which i post eventhough i specified it, so i post it here

    #2
    I recommend using the BehaviorTrees with BlackBoard and EQS. Especially with the addition of EQS what you are looking to do here is very simple, and it's then easy to add more behaviors to it on top.

    All of your move code can be removed, instead make a EQS that sets a targetlocation on the Blackboard, and then put a MoveTo node that goes to the targetlocation. Then make a BehaviorTree task that rotates to face player. An InterpRotation node on the Task graph makes it easy, don't return as a success until the rotation is complete.

    I found the EQS documentation easy to follow: https://docs.unrealengine.com/latest...art/index.html

    Comment


      #3
      Thanks a lot for your quick Response!
      i was a bit reluctant about using behavior trees, as it seemed very complicated the fisrt time i tried using it, i'll try following the documentation and do as you said.

      If i manage to make what i intended i'll post my results in thhis thread, it could probably help those who encountered the problem.

      Thanks again!

      Comment

      Working...
      X