AI Random Roam area clamp

Hey, I have a simple random roam setup for my ai character but i would like it to choose from a clamped area in front, like for example 90 degrees. Any idea how can i approach this?


Because for now he walks like A and i would prefer B style, even with curves if possible.
Untitled-1

Hi, last post here Get Random Point in Navigable Radius (Can this be forced into a cone?) - #5 by TheFlow3k

So you could just get a random point that you allow (in your 90 degree cone), then check whether that is navigable by using “ProjectPointToNavigation”, repeat until you find one or have enough iterations and assume there is none.

Or you could also use EQS (cone generator), AFAIK the parameters of the generator can be made variables and then you can randomize them.

Thanks for the reply. I added a cone mesh as a child of the actor but i can’t find a node like Get random point of cone. What am i doing wrong?

AFAIK there is no node like “GetRandomPointOfCone”, you need to do it manually yourself. You could choose a point of origin, an angle and a radius. Then a random point inside the cone would be

x = origin_x + cos(random_angle)*random_radius
y = origin_y + sin(random_angle)*random_radius
z = z

Then you take that point, and use “ProjectPointToNavigation” (and I would not set the query extend there to all 0, since AFAIK that is how far it looks to get that point onto navigation, so z should not be 0).

hmm, sorry but i don’t know what an AFAIK is and where to type in the provided code. Could You elaborate or link some documentation?

AFAIK means “as far as I know” and you can do it like this:



And you would then call “GetRandomPointInNavigableCone”.


That above will generate points in a cone with a certain orientation. If you want to generate them based on some cone direction, you would need to rotate the generated points around the origin (by the degree you want the cone to be rotated).

EDIT: And “Angle Range” should be in degrees (the sin and cos there are in degree)

Wow, thanks for the detailed answer, i really appreciate it!!! So i replicated Your Functions and called it like this. Unfortunately, the character doesn’t move. What could be the problem?

You can test that it finds points via something like this here (where I tested it myself it worked):

And the “Test” event is marked “Call In Editor” so that you can directly call it inside the editor without starting the game.


And by the way, I would generally use behavior tree for what you’re doing above, not EventTick (I don’t think that is causing your problem though, just generally).

Thanks a lot for the detailed answers! Greets :slight_smile: