mirror of
https://github.com/Xevion/Boids.git
synced 2025-12-14 16:11:05 -06:00
basic Boids class setup
This commit is contained in:
30
Assets/Boid.cs
Normal file
30
Assets/Boid.cs
Normal file
@@ -0,0 +1,30 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
public class Boid {
|
||||
private Vector2 _position;
|
||||
private Vector2 _velocity;
|
||||
|
||||
// Renders the Boid. If focused, the
|
||||
void Render(bool focused = false) {
|
||||
|
||||
}
|
||||
|
||||
// Returns the next position the Boid will be moving to
|
||||
Vector2 NextPosition(List<Boid> boids, float[] magnitudes) {
|
||||
|
||||
}
|
||||
|
||||
// Cohesion: Steer towards center of mass of flock
|
||||
Vector2 Rule1(List<Boid> flock) {
|
||||
|
||||
}
|
||||
|
||||
List<Boid> GetFlock(List<Boid> boids, float radius) {
|
||||
List<Boid> flock = new List<Boid>();
|
||||
foreach(Boid boid in boids)
|
||||
if(Vector2.Distance(this._position, boid._position) <= radius)
|
||||
flock.Add(boid);
|
||||
return flock;
|
||||
}
|
||||
}
|
||||
3
Assets/Boid.cs.meta
Normal file
3
Assets/Boid.cs.meta
Normal file
@@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 8fa9bbc6d9eb4c368be190feba139e7c
|
||||
timeCreated: 1589638836
|
||||
@@ -1,21 +1,26 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
using Unity.Mathematics;
|
||||
using KNN;
|
||||
using KNN.Jobs;
|
||||
|
||||
public class BoidController : MonoBehaviour {
|
||||
public int BoidCount = 1000;
|
||||
public int BoidGroupRange = 1.0f;
|
||||
|
||||
// Start is called before the first frame update
|
||||
void Start()
|
||||
{
|
||||
// Controller Attributes
|
||||
public Rect space;
|
||||
|
||||
// Swarm Attributes
|
||||
public int boidCount = 1000;
|
||||
public float boidGroupRange = 1.0f;
|
||||
|
||||
// Bias changes how different rules influence individual Boids more or less
|
||||
public float separationBias = 1.0f;
|
||||
public float alignmentBias = 1.0f;
|
||||
public float cohesionBias = 1.0f;
|
||||
|
||||
private List<Boid> _boids = new List<Boid>();
|
||||
|
||||
void Start() {
|
||||
|
||||
}
|
||||
|
||||
// Update is called once per frame
|
||||
void Update()
|
||||
{
|
||||
|
||||
|
||||
Reference in New Issue
Block a user