0
\$\begingroup\$

I have a project where I have 1 character (playable) and 2 NPC's (AI).

The NPC's are programmed to meet 2 target points.

Below is an image to facilitate understanding:

enter image description here

As you can see, this green path is the full extent of the terrain that both my character and NPC's can walk through.

I know that in order for my character to traverse the full extent of the terrain, it is only necessary to add a nav mesh bound that covers the entire length of the terrain, but doing so the NPC's would cut their path:

enter image description here

CODE NPC'S:

enter image description here

I've made the target variable editable, so I can choose the target in the level editor.

I would like to know the simplest way to make the playable character go all over the terrain and the NPC's to follow the green route.

\$\endgroup\$
  • \$\begingroup\$ When you've got this set up, what is your AI not doing that you're expecting them to? \$\endgroup\$ – Stephen May 10 at 7:10
  • \$\begingroup\$ My AI is doing everything correctly. I happen to want her to do this path that it does regardless of the nav mesh bound. \$\endgroup\$ – Boneco Sinforoso May 10 at 13:22
1
\$\begingroup\$

Since you want to have a nav mesh over the whole level but make the AI only move to the location in the direction and angle you want them to, you need to switch from SimpleMoveTo and AIMoveTo.

AIMoveTo

You'll also need to add extra target points and set the AI on a path to one target point then, On Success, move it to the next.

The target points do not have to be an actual Unreal Target Point, they can be any actor you'd like them to be.

\$\endgroup\$
  • \$\begingroup\$ From what I understand, I could not want the NPC's to move the way I want it to have made only one point, correct? \$\endgroup\$ – Boneco Sinforoso May 10 at 23:29
  • \$\begingroup\$ You can use NavigationFilters, but detour with separation doesn’t respect them (atleast last time I checked it). \$\endgroup\$ – ColdSteel May 11 at 22:07
  • \$\begingroup\$ If you want a super specific path - you can just put a spline and move along the spline... without navigation and all the sadness of UE4. \$\endgroup\$ – ColdSteel May 11 at 22:08
0
\$\begingroup\$

Creating two volumes of motion is impractical, in theory it is possible, but it is much more laborious, less practical and less fluid (worst performance).

Much better (for the situation) just define in more detail the path of the NPC. And for that, just add more target points (in the case of the question, just add 1 more).

The nave mesh bound would cover the entire extent of the map, so the controllable character can go anywhere.

Look the image:

enter image description here

Purple Square => controllable character

Red Circle = NPC

Blue X = target point 1

Black X = target point 2

Note that this way the NPC will make the desired path without affecting the controllable character.

In the answer to this question, you have a very easy way to do this:

How do one NPC follow a succession of target points?

There are numerous ways to do the same thing, it's up to you to decide which one to use. You could use the AIMoveTo instead of using the Simple Move. Even use navigation filters (refer to this in Stephen's answer)

\$\endgroup\$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.