basic Boids class setup

This commit is contained in:
Xevion
2020-05-16 10:42:49 -05:00
parent 39af1b95f7
commit e5588178eb
3 changed files with 48 additions and 10 deletions

30
Assets/Boid.cs Normal file
View 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
View File

@@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: 8fa9bbc6d9eb4c368be190feba139e7c
timeCreated: 1589638836

View File

@@ -1,21 +1,26 @@
using System.Collections; using System.Collections;
using System.Collections.Generic; using System.Collections.Generic;
using UnityEngine; using UnityEngine;
using Unity.Mathematics;
using KNN;
using KNN.Jobs;
public class BoidController : MonoBehaviour { public class BoidController : MonoBehaviour {
public int BoidCount = 1000; // Controller Attributes
public int BoidGroupRange = 1.0f; public Rect space;
// Start is called before the first frame update // Swarm Attributes
void Start() 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() void Update()
{ {