Assignment 10- Bee swarm

ConceptThis project explores swarm behavior as something emotional rather than purely biological. I was interested in how a group can move together without ever fully becoming one thing. Instead of treating the bees as literal insects, I approached them more like particles of attention or energy that are constantly negotiating space, attraction, and distance.

The interaction is centered around the mouse, which acts almost like a shifting force field. The bees are drawn toward it, but never fully settle. They resist each other through separation forces, creating a constant tension between clustering and dispersing. I wanted the movement to feel alive, slightly unpredictable, and never static.

Visually, the hexagonal grid references a honeycomb structure, but it is not rigid or dominant. It behaves more like a responsive environment. When collisions happen, the grid lights up and ripples expand outward, turning invisible physics interactions into visible traces. This transforms collisions from purely mechanical events into something more atmospheric and expressive.

Inspiration came loosely from flocking systems, especially murmuration patterns, as well as particle simulations that feel soft and organic rather than rigid. I was also thinking about systems where small interactions leave temporary marks in space.

Code Highlight (What I’m Proud Of)

One part of the code I’m particularly proud of is the behavior system where multiple forces are layered together to create the swarm effect:

// SEEK MOUSE
let seek = p5.Vector.sub(mouseVec, pos);
seek.normalize();

Body.applyForce(b, b.position, {
  x: seek.x * strength,
  y: seek.y * strength
});

// SEPARATION
if (d < 25) {
  let escape = p5.Vector.sub(pos, otherPos);
  escape.normalize();
  escape.mult(0.0002);
  Body.applyForce(b, b.position, { x: escape.x, y: escape.y });
}

What I like about this is that the motion is not coming from one rule, but from multiple competing forces. The bees are simultaneously being pulled, pushed, and slightly randomized through noise. That layering makes the system feel less artificial and more like something emergent.

Embedded Sketch

Milestones and Challenges

Milestone 1: The Hexagonal Environment

Setting up the basic p5.js canvas and draw the background pattern. I didn’t add physics yet, just using math to tile a grid of hexagons.

Milestone 2: Introducing Physics & Spawning Bees

Bringing in Matter.js. I created the physics engine, turn off gravity so things float, and spawn our “bees” (physical circles) into the world.

Milestone 3: Following the Cursor

Applying physical forces to make the bees seek the mouse. I also added a speed limiter so they don’t accelerate infinitely and fly off the screen.

Milestone 4: Organic Swarm Movement (Separation & Wiggle)

I added a “Separation” force that pushes the bees away from each other if they get too close, and Perlin noise to make them wiggle like real insects.

Milestone 5: Detecting Collisions & Drawing Ripples

I Introduced the Events.on() listener. Whenever the Matter.js engine detects two bees colliding, it spawns a new Ripple object at that exact coordinate, which expands and fades away.

Milestone 6: The Final Polish (Hexagon Glow)

During collisions, I now check the distance between the collision point and our grid of hexagons. If a hexagon is close, its glow value is set to 1. In drawHexGrid, this glow translates to opacity, fading out slowly over time using h.glow *= 0.96.

Reflection and Future Improvements

Looking back, the project successfully explores how forces can be layered to produce emergent behavior. The combination of attraction, separation, and noise creates a system that feels alive and responsive rather than scripted.

The collision system works well visually, but it is currently limited to collisionStart. If I were to develop this further, I would explore additional collision events like collisionActive and collisionEnd to create more sustained or evolving effects, such as continuous glowing or gradual decay tied to contact duration.

I am also interested in pushing the visual language further. Right now, the bees are quite minimal. There is potential to experiment with scale, transparency, or trails to make the swarm feel even more atmospheric.

Another direction would be to shift the interaction away from the mouse and explore autonomous behaviors, where the system evolves on its own or responds to less direct inputs.

I feel like this project helped me think of physics not just as simulation, but as a design tool for shaping movement, interaction, and visual rhythm.

Leave a Reply

Your email address will not be published. Required fields are marked *