I’ve been looking into AI for my game lately, and I have determined that I need some type of functionality similar to boids or flocking; however, I only need it in two dimensions being that my game will involve the movement of ground animals. I want to program a pack of wolves, but I’m not sure what I should do honestly. I’ve tried modifying the boid script to where it doesn’t move in the y direction, but my attempts have been unsuccessful. If I could have some guidance, it would me much appreciated… thanks! I have been using this as a start here
There is a pretty good implementation of boids/opensteer called UnitySteer available from here. I’ve used this in the past to achieve some very nice flock-like simulations, but it’s been a while since I’ve looked into the details. Depending on just what you want to achieve, that package may give you what you want, or be complete overkill for a relatively simple problem.
Alternatively, looking at the scripts in your link, they should only require two changes to prevent movement in the y-axis. In Boid Controller.js, change:
var position = Vector3(
Random.value*collider.bounds.size.x,
Random.value*collider.bounds.size.y,
Random.value*collider.bounds.size.z)
- collider.bounds.extents;
in the start() function to:
var position = Vector3(
Random.value*collider.bounds.size.x,
0,
Random.value*collider.bounds.size.z)
- collider.bounds.extents;
and in Boid Flocking.js, change the first line of the calc() function to:
var randomize = Vector3((Random.value *2) -1, 0, (Random.value * 2) -1);
If those don’t work, or if you need any help setting up UnitySteer, leave a comment and I’ll see if I can help further.