x

Search in
Sort by:

Question Status:

Search help

  • Simple searches use one or more words. Separate the words with spaces (cat dog) to search cat,dog or both. Separate the words with plus signs (cat +dog) to search for items that may contain cat but must contain dog.
  • You can further refine your search on the search results page, where you can search by keywords, author, topic. These can be combined with each other. Examples
    • cat dog --matches anything with cat,dog or both
    • cat +dog --searches for cat +dog where dog is a mandatory term
    • cat -dog -- searches for cat excluding any result containing dog
    • [cats] —will restrict your search to results with topic named "cats"
    • [cats] [dogs] —will restrict your search to results with both topics, "cats", and "dogs"

Office Holiday

Epic Games' offices will be on holiday from June 22nd to July 7th. During this period support will be limited. Our offices will reopen on Monday, July 8th. 

AI: Finding Direct Path to Target

Hello UE4 Community,

Is there any way to check if a straight path from one actor to another is free? I would use the "Pathfinding Context" input for "Find Path to Actor Synchronously", but there doesn't seem to be any documentation about what exactly I should plug into it.

Context
The AI logic supposed to go like this:

  1. Go toward the target actor (the player in most cases)

  2. While moving, check if a straight path to the target is clear

  3. If it is, stop moving

  4. Pause for a "windup"

  5. Dash toward the target (travel along the ground a certain distance over time)

  6. Pause for a "cooldown"

  7. Repeat

The problem comes in when I want to check for collisions along this path. When using a capsule trace, it only goes in a straight line, so any time the player and enemy are on a different elevation, the collision check will not be accurate. I'd much rather use the navigation system to my advantage by simply checking if I can move in a straight line on that path without running into any collisions, but I haven't found a way to do this.

NOTE: Even though I placed this in the Blueprint Scripting Section, I am willing to try a C++ solution. While I am by no means an expert with C++, I do have a decent amount of coding knowledge.

Thank you,
Quiteblank

Product Version: UE 4.12
Tags:
more ▼

asked Aug 29 '16 at 07:08 PM in Blueprint Scripting

avatar image

Quiteblank
3 1 2 4

(comments are locked)
10|2000 characters needed characters left
Viewable by all users

1 answer: sort voted first

The PathfindingContext pin should be okay in most basic uses without hooking anything up to it. Just give it a reference to your pawn (the thing doing the pathfinding) if it isn't.

To tell whether you have a straight shot to the player, you can do one of two things - you can check to see if the length of the Path Points array provided by FindPath* is

more ▼

answered Aug 29 '16 at 11:10 PM

avatar image

Teiwaz
629 26 29 55

avatar image Quiteblank Aug 30 '16 at 12:22 AM

Thank you very much! That was extremely helpful and it solved my issue. For anyone who is curious, my implementation of the first suggestion is attached. alt text

capture.png (103.2 kB)
(comments are locked)
10|2000 characters needed characters left
Viewable by all users
Your answer
toggle preview:

Up to 5 attachments (including images) can be used with a maximum of 5.2 MB each and 5.2 MB total.

Follow this question

Once you sign in you will be able to subscribe for any updates here

Answers to this question