Skip to content

Commit b980e94

Browse files
committed
Update Readme with brief overview and extension ideas
1 parent 3db07a3 commit b980e94

File tree

1 file changed

+51
-1
lines changed

1 file changed

+51
-1
lines changed

README.md

Lines changed: 51 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,51 @@
1-
# UnityBoidsExample
1+
# UnityBoidsExample
2+
3+
This Unity project is a very simple boids implementation.
4+
5+
Some general features to look out for:
6+
- The object representing a "boid" can be found in the Prefabs folder. This is a game object with a script as well as a child object which holds the 3D model. The child object is so that the 3D model can be rotated relative to the main game object.
7+
- Boids also have a velocity parameter; the velocity in the prefab is the default starting velocity for boids.
8+
- The boids are generated by the "Hive Mind" object, controlled by the corresponding script. It generates boids randomly in a cuboid.
9+
10+
## Boid Behaviour
11+
12+
- Boids are controlled by the `HiveMind` and their own `Boid` class.
13+
- Boids update their position based on their velocity at a given frame, and the time length of that frame.
14+
- Boids orient themselves at every frame in the direction of their current velocity.
15+
16+
- `HiveMind` controls flocking behaviour.
17+
- Cohesion: boids move towards centre of the flock i.e. average position of all boids.
18+
- Repulsion: boids withing a "personal space" radius move away from one another.
19+
- Alignment: boids tweak their velocity slightly towards the group velocity (average velocity of all boids) at each time step.
20+
- Each is controlled by an independent acceleration.
21+
- These accelerations are serialised so you can play with them in real time while the game is running to explore their effects!
22+
23+
## Controls
24+
25+
- There is some interactivity in this program.
26+
- Camera controls are in the `CameraController` script on the `Camera` object.
27+
- This uses the old input system because it was faster and clearer than faffing with the new one.
28+
- Camera toggles between 2 modes: follow, and ... not follow.
29+
- In follow mode there are no other controls, it just follows a particular boid (the first in the list of generated boids).
30+
- In the other mode you reset to the origin (initially looking at the centre of mass of the boids), and you can control the camera orientation using the arrow keys and the mouse scroll wheel.
31+
32+
# Extensions
33+
34+
I strongly encourage you to try new things! The fun of Unity can be imagining something and then realising that you can make it happen, and then see it play out in front of you. Some things you can do if you don't know where to start:
35+
36+
- Make boids only influenced by boids within a certain radius, rather than flying towards centre of mass or aligning with total group velocity.
37+
- Give points a conical or other model of awareness, so they are less aware of things behind them than in front for example.
38+
- Add leadership behaviour or randomisation so boids break away and don't form stable configurations.
39+
- Add landscapes, and avoid crashing into them.
40+
- Add landing behaviour!
41+
- Add a gameplay element e.g. a cannon the shoot the boids. Detect hits and eliminate struck boids; other boids should scatter!
42+
- Add a predator **hawk boid** to hunt the other boids on the wing, and program in hunt and flee behaviour.
43+
- Add boid variations, so they are different sizes and colours, have different initial velocities, perhaps varied max speed or acceleration parameters etc.
44+
- Bound the boid space so they never fly away to infinity!
45+
- Add animated boids that look nicer than my giant flying pills!
46+
- Create multiple boid species with separate flocking.
47+
- Consider how and if you would want these flocks to interact?
48+
- For example you might want boids of different species to still avoid colliding with each other (repulsion rule), but _not_ to stay together (cohesion and alignment). How would you handle this exchange of information between boid species?
49+
- Detect boid-boid collisions and have them explode and scare away other boids! (The Unity particle system could be good for explosions.)
50+
- A less pyrotechnic alternative could be for them to fall down or something.
51+
- Limitless other possibilities!

0 commit comments

Comments
 (0)