Pathfinding in Unity, a demo

A small demo of my first ever 3D steering and pathfinding implementation in Unity.

I’m using Aron Granberg’s A* to drive the pathfinding, though it could be swapped out at whim.

All of the steering and obstacle avoidance was done by me. I was originally using UnitySteer, but I wasn’t happy with how it was working out and so decided it was best I rolled my own in order to learn. It’s all stupidly simple but works pretty well.

I am pretty happy with how the tanks move and handle dynamic situations.

Omg, they look so cute, kawaii!

It must be great to see your custom little creatures trying their best to move around.

This stuff looks great, I wish I could program like that. My incredibly stupid AI consists of a standard Unity script + a few extra lines and doesn’t play well.

Do you think it’ll take long for a non programmer to learn to make such an AI?

Great work,

Very cool. I’m currently working on this myself, and was in exactly your same boat… I didn’t like how UnitySteer was setup, so I’m rolling something more simplistic.

I just wanted to ask you, how do you combine your steering forces? So you simply sum your Seek and CollisionAvoidance behaviours to get around obstacles? Do you apply a greater weight to collision avoidance? Or do you have some other method? Currently my units are detecting collisions and are able to seek to their endpoint, but aren’t avoiding obstacles under all scenarios.

I’m glad other people are working on this and I must say well done!

UnitySteer has some neat code in it, but it made too assumptions that just aren’t true for my game. I know you’re supposed to implement your own custom vehicle class to handle things, but I found that I was writing so much code, I’d rather just stick it in a separate class and keep it clean and centralized.

I just sum my forces. I initially did weigh obstacles greater than seek, but I found that my tanks would get too caught up in steering to avoid obstacles. I wanted them to keep trying to move towards a waypoint even if they were stuck. I initially started to implement reversing and other strategies to un-stick the tanks, but found that just a straight up combination of seek+avoid worked better.

And thanks, I am pretty happy with it, especially since it’s my first complete pathfinding+steering implementation done in 3D.