Posts

Showing posts from February, 2021

Game AI - Obstacle Avoidance + Flocking (In 3D!)

Image
Obstacle Avoidance! (again) but now in 3D with flocking behaviors "They say everything in life comes full circle eventually" -they      I didn't intend to revisit obstacle avoidance again so soon, but this time, it's different. The primary focus of my latest assignment was to implement flocking and obstacle avoidance (a completely different beast). Luckily for me, I had done flocking before (in 2D), and I have also done obstacle avoidance before (also in 2D, check out my blog post on it 😉). I thought the primary problem I was going to have was combining both of these into one behavior. After some thinking however, The solution I went with was pretty simple (I'll talk about that later). In order to spice things up some more, I decided to use this project as an opportunity to implement both of these behaviors in 3D and sink my toes into some of the nifty tools that Unity had to offer (there are so many tools out there that I still don't even know about).    

Game AI - Obstacle Avoidance

Image
  Obstacle Avoidance!      So you have an NPC (Non-Player Character) in a game that you want to maneuver around a scene but there are obstacles in the way, don't worry there are ways around this. Jokes aside what you are looking for is a means to have your NPC avoid obstacles. In this blog post, I hope to talk about my approach to obstacle avoidance (It might be a little Unity-centric since that is what I used) and how you can do it too! (amazing) The example of obstacle avoidance that I implemented     As you can see (in the video above) it's not perfect but it does a good job of visualizing the main points I want to make.      To start off I needed to create an NPC to maneuver the scene, I used a basic triangle sprite since it's a shape with some nice visual direction. Next, I needed some obstacles to avoid, depending on the tools you have, circles can be used as obstacles since they are easy to use for hit detection, but thanks to unity I was able to put whatever I wante