How to check if location is valid for AI

Hello!

I was wondering if anyone knew how to check if a place if valid for AI to go to. I am making a battle royale mode, and the circle needs to randomly spawn on the map and the AI need to be able to go there. I have everything else set up but the “checking if the circle location is valid” script. The AI needs to be able to move inside the circle, so nearly every location must be valid inside it.
Any help would be great!

Hello! Thanks for your help, here is a screenshot of my current setup just so it makes more sense. I should have mentioned that the circle is a storm similar to PUBG or Fortnite, as it is battle royale mode.
Thanks!

Thanks for that, I’ll try it now!

ok so after a little bit of work i may have found a solution or rather i made a script that could have some helpful hints.

the idea here is that if the character is outside the circle(sphere1) then you would get the point on the boundary of the circle that is closest to the character and move them just inside that point *script at bottom right). i did all of this script in the spheres bp so you would need to modify it a bit to make it work from the ai’s point of view.

if you have questions on this let me know, i know its a bit confusing to see and understand and i didnt really explain it.

i figured it was a system like that. that script your showing has a few issues. first from what i can see your creating a random location between -3k and 3k of the world origin thats fine but may not give the result you want, the issue here is that the get rendompoint in nav radius isnt actually doing anything since you have the radius set to 1. what your basically doing is getting a random location then getting a random location within 1 unit of the first location. i would either eliminate the section prior to the make vector or the get random in nav node. another issue here is your using the set actor location. now im assuming these are supposed to be bots that move and stay in the circle. ok so why the set actor location is bad in this case is that it will basically teleport the character to the new location. this is fine for initial placement but bad if you have your player fighting them and then they just disappear. instead of the set actor location node i would use something like the ai move to node which allows the character to run to the location. for example see the picture below that i based on the previous picture posted, in this example i made a basic roaming ai character that will move to a point within 1000 units of itself and once it gets there it will move to another location in the same manner, then every 15 seconds it will move to a location within the circle. so its a simple basic roaming ai that has one trick to make it look smarter. now you could accomplish this quite easily in a behavior tree as well (this was just easier for testing). so in summary you need to come up with a method of movement that doesnt teleport and aside from that its hard to tell you what you should do give the small snippet of your script.

personally i dont like the get random location and see if its in the circle kind of approach since it could give a location quite far away or you could have to run through a function many times to find a location that works. i would rather give a location that i know is in the circle then add a bit of a random offset from there.

What engine version are you using? I cannot seem to find it.

I cannot seem to find “closest point on Sphere to line”

245713-657.png

cant find what? im in 4.17 atm

opps i just realized that i have one of Rama’s plugins (victory plugin) installed on this project and the closest point on sphere to line is from that plugin. my bad sorry about that. you could get the plugin or go for a different method. like do a line trace to see where the edge of the circle is.

245748-gerag.png

I cannot find it on version 4.19 or 4.18.

guess you didnt see the comment above before posting. i forgot that i was using Ramas plugin and that node is one that comes with that. so youll either need to find the plugin or use a different method. from what i remember the plugin if free and free to use as long as you credit Rama in your game.

This image is for the circle, not the bots.

I tried your system but it still does not work as I think that the circle needs to be in an area where the AI can navigate. This image is the old system I had for the bots.

I used the system of manually placing points where the circle can go and it worked! Thanks so much!

you would need to make a script that compares locations, basically you would need to get teh area of the circle and check if the point is in range. theres a node for this for cubes (is point in box) but for a circle youll have to figure out the math. or you may be able to get the circles radius then use a distance calculation. get circle location, get distance from point to circle location, is distance less than radius? if yes then your in range, if not pick another point.

so glad every link in these forums is now broken…