[RELEASED] Flock Box DOTS 2.0 - Flocking simulator

5604532--579835--CardImage_420x280.png

Flock Box in the Asset Store

Stress Test Demos Available on itch.io

Flock Box is a highly customizable flocking simulation based on the Boids pattern. It is easy to add and tune behaviors without any scripting at all, but it can also be extended with custom behaviors.

Included behaviors
Alignment,
Cohesion,
Separation,
Containment,
Seek,
Pursuit,
Arrive,
Flee,
Follow Leader,
Avoidance,
and Wander.

Individual behaviors can be combined to create compound behaviors. For instance, Wander + Seek produces Foraging.

2 Likes

I bought your plugin recently and it is quite good! I really like the modular design for the behaviors. I did run into small problems and have some questions.

I am trying to simulate a herd of animals (in this case deers). Things are looking good, but one thing that is bothering me is how fast the boids turn. It seems to do this behavior where it looks left and right in continuous and quick burst. Unfortunately this looks a bit weird and almost jittery in some cases. Is there anyways to smooth out the left to right behavior? I know you are using a lookat(velocity) function and you can certainly smooth that out, but I wanted to see if I could approach that issue directly.

I took a video of a herd of deer using your plugin and the terrianboid example:
uliyu4

The other question I have is is there a way to have a queueing behavior with a group of boids? I’d to replicate a behavior you occasionally see in herds and schools of fishes, is where they line up rather than just bunch up together. This is something I’d really like to implement in the future.

Here is a image and article about the queue behavior:

Thanks!

Twitchy movement can be a recurring problem when trying to find the right balance of steering weights and speed/force. In this case I would recommend lowering the Separation weight.

That being said, I recognize that some secondary smoothing can be really useful for getting your behavior all the way to where you want it to be. In v1.6.1 I’ve started experimenting with a script called TwitchDampening (see the the ColliderAvoidBoid prefab for an example; it is applied to the child “pyramid” object). I’m considering rolling this functionality into SteeringAgent in a future update, but I don’t necessarily want it to be the first solution users turn to because it won’t always be able to hide an underlying issue with the weight tuning.

I’m adding Queue to my backlog of steering behaviors to implement. It will require some minor changes to the way neighbors are discovered (currently they will only look within a radius around the agent and in a straight line ahead), but it seems like a worthwhile feature!

2 Likes

Thank you so much! i’ll try those adjustments you mentioned.

I am really excited to hear you are considering the add the Queue functionality. I think that would really help out with different flocking scenarios ( school of fish, crowd of people, army formations ect. )

Hello,

Does your system allow the flock to fit inside a specific area ? for instance an aquarium, i dont want the fishes to swim outside the area, is this possible ?

Yes, that would be controlled by the Containment behavior.

Does this use ECS? Or does this run on CPU on main thread? Do you have any bench marks for specific hardware? would be helpful to see that in description. Both on mobile and PC would be awesome. Stop

Anyways awesome work!

Thanks! The next update is going to include a DOTS implementation (and require minimum Unity version 2019.4 LTS). I don’t have a release date but it’s currently in development. For the moment everything runs in the main thread. I’m going to follow up with some benchmarks soon.

2 Likes

Great work with this! The amount of customization is very impressive! I’ve been starting to pick apart your code a bit because I would like to add a “walk” speed, with maxSpeed being as fast as the objects move only during fleeing and/or avoiding or the like. I am working on herding sheep and I’d like the sheep to casually stroll as they are “eating” (using the arrivalBehavior) and when being forced to move by the shepherd or dog, they pick up the pace depending on how close the opposing actor is to them - or possibly act a little more erratically when being chased by a predator.

If you have any suggestions for a min/max speed within your code, I’d love to hear it. Again, very nice work!

Oh, another question that I’m going to dig through the code for: Does an object HAVE to be nested inside of the flock box object for the boids to interact with it? I was able to get my terrain working properly outside of the box, but I can not seem to keep my player outside of the box and still have the sheep avoid him.

3 Likes

I’ve made stress tests (Windows + Android) available for download here:
https://cloudfinegames.itch.io/flock-box

On my i5 + GTX 1080 I can comfortably run 1000 agents at 60fps. Beyond that it begins to dip unless fidelity is reduced.

I would recommend having two BehaviorSettings and using a state machine to swap between them. One would be “Grazing” and have a lower maxSpeed. The other would be “Fleeing” and have a higher maxSpeed as well as a Wander behavior to add some erratic movement.

You’ll be able to detect if a SteeringAgent is fleeing using this line:

myAgent.GetAgentProperty<bool>(FleeBehavior.fleeAttributeName);

I’ve attached a script you can use instead of Agent that will not rely on parenting, just be sure to call JoinNeighborhood(FlockBox flock).

6125135–667589–ExternalAgent.cs (1.05 KB)

3 Likes

@check_marc That’s a great idea, thank you! I will be doing that. I’m new to unity (though, not exactly new to C#) and I’m hoping to make a mindfulness game - I think this is the next trend in casual gaming. I’ll absolutely try that, thank you!

Thank you for this script! You went way out of your way to help me out here, I greatly appreciate it! I will put this in today and also will be giving you an awesome 5-star rating on the unity store. You’ve done some great work here and your support on this forum is awesome!

2 Likes

Hey I am just playing around with this, and it is really neat so far! I am very new to Unity, and using Playmaker, as I have no coding background. How can I make the player the leader or the target of a Seek? I see I can Tag my player as leader, or put him as a child of the flock box, but it does not seem to affect behavior of the Followers.

1 Like

@Dhagz does your player object also have an Agent component?

1 Like

Hey thanks that works but now I can’t control my player anymore! I will play around with it a bit, thank you for the tip.
EDIT: Character is raised into the air when script agent is enabled. He will turn but not move. Disabling agent I can move, flock spins in spot with no leader, then follows again when script enables and I can’t move again. I understand that something in my move controller will only allow me to move when i am touching the ground, and / or something in your agent script raises me into the air. If i raise the ground when script is on I can move again and it works wonderfully!

1 Like

@Dhagz you may need to expand the size of the FlockBox. The only time Agent.cs will move the object is to snap it to the edge of the FlockBox when it is outside.

1 Like

Hi, I am climbing the walls trying to use containment behaviour to add fish to a river. I have two issues that are driving me insane. Firstly the Flockbox is invisible so I have no way to check dimensions or allign it to my terrain. Secondly even if I do get it roughly in place which Ive managed at times, when I save and start the game it moves seemingly of its own volition. I’m 7 hours in! I am getting an error; Artifact meta info not present for hash 00d169d9ae741f5fc8f6772e2381ecc1. Any advice would be much appreciated. Thanks bodi.

@bodionafun There’s a checkbox on the FlockBox component for “Draw Gizmos” under the Debug dropdown (you will also need Gizmos to be enabled in your Scene view). This will help you line it up with your environment.

I would check for any physics components in its hierarchy that may be creating unexpected movement; there’s nothing in FlockBox that will move the GameObject.

I haven’t seen that error before. If it’s causing problems for you email me at marc(at)cloudfinegames.com and I can look into it.

@check_marc Hi, I’m really interested by purchasing your asset.
But I would like to check with you if there are any restriction with WebGL & IOS builds ?

@Octarina there are no such restrictions. This asset will work on any platform.

1 Like