Raycast collider detection on obstacles while moving

I’ve got no clue where to start, so I thought this might be the right place to ask for a hint or tip: I have a player which moves according to a grid. I’m generating a random level, with obstacles at random generated places.
I’ve already tried to midify Prim’s Algoritm so that it can give a boolean to my player: is walkeable or not, though I don’t think this is the most efficient way. The thing I want is that my player casts a ray in front of him to detect if there’s a collider on it’s path and automatically walk around it. Though, as I’ve stated before: I’ve got no clue where to start, so every little help is welcome. If you need to see any script parts, or if anything is unclear, please tell me so, will also help me to specify my questions more in the future. Thanks in advance :slight_smile:

yea thats pretty much what A* does in a nutshell. What your looking for. There is a free and a few paid versions of it though in the unity asset store.

You can also find code for one online to view.

DO NOT WORRY ABOUT EFFICIENCY.

That is something you can check at the very end.
Modern processors can do ALOT per second. It would take alot of resursive calls or like search the entire scene 60 times a second or something to really pressure the system.

honestly the difference between say using an float when you could have used an int. You could do that through pages and pages of code and produce no meaningful effect on FPS or system load.

The A* algorithm optimized can search like a hundred thousand nodes per second. But then again you whole map is going to end up being like 100 so who cares. :stuck_out_tongue: