Help detecting the nearest point of contact?

Hello all!

I don’t know what the proper terminology for this would be, but I am essentially trying to create an object that constantly detects the nearest point of contact in the environment with a raycast.

Does anyone know how this could be done, and/or what concepts I would have to gain an understanding of in order to get something like this working? I made this animation in blender to hopefully help visualize what I’m going for.

Thank you so much to anyone out there and good luck to you all on whatever project you’re stressing about!