NPC walk a certain path with interruptions

Hello there beautiful people,

I have started using UE5 & Blender recently with 0 experience in development and 3d modelling.
Saying so, I’m having an absolute blast with it and started trying to make a basic game.

Now I’ve been trying to make a NPC that walks on a pre determined pathway and stops if you as a player are to far away from it.
I have been able to create a random patrolling behavior with a behavior tree, but I can’t seem to figure out how to make a NPC do what I require it to do.

Does anyone here have experience with this?
I want the character to run down the path through the forest.

If possible since I don’t have a lot of experience yet, keep in mind im a noob at this while explaining :smiley:

Hey @Bobsondo!

One thing you could do is have a collision volume (sphere) around the NPC, with ON collision overlap allowing the run and the END collision overlap telling it to stop.

Another thing would be on the behaviour tree, you could have a SERVICE on a node that checks distance between the player and the NPC and if it’s above/below a certain distance toggle a Bool on the behavior tree that would block out that part using a decorator. Such as:
Service: Get distance and set bIsInRange (this checks constantly)
Decorator: if bIsInRange is SET (meaning returns True)-> do the movement.

Hope that helps! :slight_smile:

1 Like

Hey @Mind-Brain first of all thankyou for your reply :slight_smile:

That are some great pointers you give there,
My problem is also that I am an absolute beginner so im not sure how to implement what you are saying sadly :frowning:

This picture basicly shows how far I have gotten;

I’m not sure, and not even sure how to do it but I believe I need to do the following now;

  1. Set a way to mark the splinepath as a route / location,
  2. Get the behavior tree to recognice the path and a way for the character to follow it
  3. get an interruption if the player is to far away

Is there any chance you might be able to give some advice with a screenshot withh blueprint nodes on what im searching for?

I have found some tutorials of people that use many different ways to make an npc follow a path, but I want to keep the logic universal and have all blueprints in the behaviortree and tasks > not in the characterblueprint if possible.

If anyone knows a way how to get this done, it wil lbe very much appreciated

Current Situation:

  • I have managed to make a behavior tree that makes my character walk a pre determined path made by path points
  • I added a decorator on the sequencer that only runs when I am in a certain range of the NPC, Thanks @Mind-Brain :slight_smile:

The last problem I face is that when I am in a certain range of the NPC, it will run my sequencer and move the npc to the next path point. but I actually want to be able to interrupt the NPC midway to the next path point of the player is to far away.
Currently he will finish the sequence until he reaches the next point. is there a way to interrupt at any given moment? like forcing the sequence to stop?

For those with the same question, the solution is as following;

  • Set up a behavior tree that makes your NPC follow a pre determined path
  • Add a decorator to the sequencer with logic to determine the variable you seek, mine was if the player is close enough the npc starts moving. you can also select “Observer Abort” to “self” which means that if you no longer meet the conditions, the branch is cut of and instantly stops executing.
1 Like