AI that can move around objects

I’m working on code in java on AI, I want the AI bot to move towards something (player, waypoints ect.) and if a wall or something is in the way to look for a way around and move. I tried using physics.raycast for this, I can get AI to recognize objects in the ray and move strait for them but not around wall dose anybody know what to do or a tutorial that can explain it to me.

Thanks for the help

P.S. I know there is the angryant *A pathfinding but I don’t want to use a prebuilt code

Notneo, if you’re a fan of re-inventing the wheel, you certainly don’t have to use tested, optimized code for pathfinding and can do it yourself. The A* algorithm and Dijkstra’s algorithm are explained on their respective Wikipedia pages and there’s even more detail on their references pages. :slight_smile:

When I Googled “pathfinding”, my second hit was the tutorial, “A* Pathfinding for Beginners”:

http://www.policyalmanac.org/games/aStarTutorial.htm

There was a great tutorial series on youtube that wen through just what your looking for, I’ll see if I can find it again, and I’ll post the link here. Ok here’s the link to the first video tutorial, the guy that made this one, SteamisM50 has a whole series on it, I found it to be very helpful.

EDIT: Whoops here’s the link Unity3d Ai Tutorial

If you’re not willing to use a tried and tested waypoint or navmesh approach to solving this problem, then you have a lot of work ahead of you. You can certainly deal with navigation by doing constant raycasting all over the place, and you should look into steering algorithms for this sort of thing, as well as Unity’s new(?) Spherecast. I don’t see the point, personally. Raycasting is not going to scale up for more than a handful of bots, and it’ll be a nightmare to deal with things like uneven terrain and small obstacles.

I would suggest you look into navmeshes for this. You won’t need to thrash your CPU every frame working all this stuff out in real-time, and can instead generate a mesh for your bots to walk around on based on the terrain and obstacles. I’m a fan of this navmesh package over the one you mention, but that’s purely a matter of choice. All the cool kids are using navmeshes, but there are still many uses for waypoint navigation.

ai-blog.net - ai blog Resources and Information. illustrates the advantages of a navmesh over waypoints or other half-assed approaches, complete with a comedy video.

thanks everyone for the fast replies, now I’m not bashing the a* or anything I was just wanting to do something on my own but I will look into these and maybe come up with something. Once again thanks for the help it looks like it will come in handy