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"

Get navigable point in radius with line of sight to target for AI

Hello everyone,

I'm trying to get a position for an AI to move to within a certain radius in which he has line of sight to a certain target (i.e. it is possible to cast a trace from the ai pawn to the target pawn without hitting something). I have thought about using an EQS that generates points in a grid but I don't think it is possible to pass in some kind of target where the filters should be based on (line of sight from point to target, distance from point to target). I also thought about using the navigation system from c++ but I don't quite know how to work with that navigation system.

I hope the image below clarifies it a bit, blue is the target here and red has to move to the right(R) position while W would be closer but does not give him line of sight. alt text

Any answer in either blueprint or c++ would be greatly appreciated! Bonus points if it could be extendable to other conditions!

Product Version: UE 4.11
Tags:
sightcheck.png (9.1 kB)
more ▼

asked Apr 24 '16 at 01:14 PM in C++ Programming

avatar image

Truun
135 9 62 20

avatar image mtrebi Apr 24 '16 at 07:33 PM

Can you give me more details please? The Line of Sight is a cone or is just a straight line? Maybe a draw would be helpful.

avatar image Truun Apr 25 '16 at 12:09 PM

I updated my question with an drawing, I hope that clarifies things.

(comments are locked)
10|2000 characters needed characters left

1 answer: sort voted first

Hi,

I think EQS would fit your needs. Here you have two contexts. The blue and the red one. What you can do is to use pathing grid. To the pathing grid add a distance test from the blue context to filter points that are closer to the blue context than a given radius. Then you can add another distance test from the red context to score those points that are closer to the red context. Now you have the points in a given radius from red that are closer to blue. To check if the points are in the the Line of Sight of the blue context you should add a Trace test. This test will do a trace from the blue context to every location returned by the previous tests and return only those that are in line of sight. With all these three tests you will obtain the positions that are closer to Red, closer to Blue and also are visible from Blue.

Even in the worst case you can create a custom test in c++ (I have done it and it is not complicated, but it is another thread).

Was this what you wanted?

Hope this helps,

mtrebi.

more ▼

answered Apr 25 '16 at 12:50 PM

avatar image

mtrebi
338 16 24 27

avatar image Truun Apr 25 '16 at 01:13 PM

Thanks for your answer, that is what I want. However, how could I set the target in that case? Would I have to, in the context, get a value from the AIs blackboard that defines the target? Or is there some way to pass that to the eqs and the context itself?

avatar image mtrebi Apr 25 '16 at 01:49 PM

In my game for example, I have defined two contexts one for the player and the other for the enemies. There you can override four functions: ProvideActorsSet, ProvideSingleActor, ProvideLocationsSet and ProvideSingleLocation depending on what are you looking for. In my case I have overriden the ProvideActorsSet and ProvideSingleActor to return one specific player/enemy or all of them. In fact, in any EQS query there is a default context called EnvQueryContext_Querier which is the context of the actor doing the EQS query.

Is it clear? Ask more if you want ;)

avatar image Truun Apr 26 '16 at 08:34 PM

Yeah its clear, thanks! It took me a while to figure out, for some reason all the tests required a locations set instead of an actor set.

avatar image Truun Apr 26 '16 at 08:35 PM

This is what I ended up with:

alt text alt text

eqs.png (68.9 kB)
context.png (187.2 kB)
avatar image mtrebi Apr 27 '16 at 08:24 AM

Glad it worked!. I do not know why all the tests required a locations set instead of an actor set. Maybe I missed something.

(comments are locked)
10|2000 characters needed characters left
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