Download

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:

663cbc8b9e5cbae7513533e2b1313b8961be47df.png

430ab85e13da33b2f926d640aba24171ac03423d.png

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:

1fd6e92b2eb2b855537ec249dda92823cce1e79d.png

002d8f2dedd0f16bb6b57eed880cedd30cbc5aa4.png

f48e2f0823a7288037b00b6c4750d8153d06761e.png

**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

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/INT/Engine/AI/EnvironmentQuerySystem/QuickStart/index.html

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!