How to tell whether there is something near a specific point?

I am making a Snake Game. I now need to spawn food at a random location. I have generate this location, but how can I tell whether there’s any obstacles near that point that the to-be-spawned food would not collide with? The method I can think of now is to add a sphere component on my food class. Then spawn the food at that location, and use its sphere component to get overlapping actors, and then check whether these actors are of type obstacle. If I do get any obstacles that overlaps with my food, then destroy this food and choose next random point to spawn. I think this method sounds awkward, since the spawning mechanism shouldn’t work like this, but I cannot think of a better solution. That’s why I am asking whether there’s any function that could tell whether there’s anything near a specific point?

Thanks,

Wcl1993

Do you have any kind of grid data that generates obsticules? or anything that you could deduce obsticule location from other then obsticule location itself

I don’t set up the grid system. I think in this way the snake can move freely. I have a spawning volume above the playground, and I use the GetRandomPointsInBoundingBox() function to generate my random location.

I think you can trace a ray from that random location to the ground and get the name of the hit actor and if that is a stone or something don’t spawn but if that is the ground so you can spawn food there :))

Thanks, saeedc! That’s helpful!