Skip to content

MistLaw/boids-unity

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 

Repository files navigation

Boids-Unity

A simple 3D Boids simulation in Unity demonstrating flocking behavior.

Overview

This project implements a basic Boids algorithm in Unity. Each agent (Boid) follows three main rules:

  1. Separation: avoid crowding neighbors
  2. Alignment: align velocity with nearby agents
  3. Cohesion: move towards the average position of nearby agents

Boids also avoid obstacles within a set radius, and movement is handled with smooth rotation and velocity clamping.

How It Works

  • Boid Controller (BoidController.cs)
    Controls individual Boid behavior. Applies separation, alignment, cohesion, and obstacle avoidance. Updates position and rotation each frame.

  • Camera Controller (CameraController.cs)
    Syncs up the editor camera with the game.

  • Physics-Based Vision
    Each Boid uses Physics.OverlapSphere to detect neighbors and obstacles within a vision radius.

  • Steering
    Uses Quaternion.Slerp to rotate smoothly toward target directions calculated from the flocking rules.

  • Velocity and Movement
    Forces are applied per frame, then velocity is clamped and drag is applied to smooth movement.

Features

  • Flocking behavior with separation, alignment, and cohesion
  • Obstacle avoidance
  • Adjustable parameters for:
    • Speed
    • Maximum velocity
    • Steering strengths for each rule
    • Vision radius

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages