flocking study curriculum
original Boids simulation video
https://www.youtube.com/watch?v=86iQiV3-3IA
1. theory
<Craig Reynolds - Boids>
https://www.red3d.com/cwr/boids/
<Daniel Shiffman - autonomous agent>
https://natureofcode.com/book/chapter-6-autonomous-agents/
<Daniel Shiffman - the nature of code - flocking>
https://www.youtube.com/watch?v=qtUV-DoSOpk
2. 2D flocking simulation tutorial
https://www.youtube.com/watch?v=payFhNs9hvs&list=PL4CCSwmU04MhfoJTJWA7n2AIB4dq6umeu
3. 3D flocking simulation tutorial
https://www.youtube.com/watch?v=2cbLQgCQ6Hc&list=PLI73C1zJus3RSwGG23RXBFualKHpEra6K&t=18s&index=24
book
the computational beauty of nature by gary william flake
Theory
3 rules of flocking
1. separation(격리)
2. alignment(배열)
3. cohesion(응집)
flocking은 separation, alignment, cohesion의 3가지 규칙을 통합하여 만들어진다.
Weight(가중치)
flocking의 세 가지 법칙의 'weight'를 적절하게 조절하여 원하는 simulation을 만들어낸다.
flocking을 control하는 controller의 역할을 함.
Unity 2D flocking simulation tutorial
SetUp
Level 스크립트 작성.
agent(member), enemy 범위(spawnRadius) 내에 랜덤으로 생성하기.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 | using System.Collections; using System.Collections.Generic; using UnityEngine; public class Level : MonoBehaviour { public Transform memberPrefab; public Transform enemyPrefab; public int numberOfMembers; public int numberOfEnemies; public List<Member> members; public List<Enemy> enemies; public float bounds; public float spawnRadius; // Use this for initialization void Start () { members = new List<Member>(); enemies = new List<Enemy>(); Spawn(memberPrefab, numberOfMembers); Spawn(enemyPrefab, numberOfEnemies); } void Spawn(Transform prefab, int count) { for (int i = 0; i < count; i++) { Instantiate(prefab, new Vector3(Random.Range(-spawnRadius, spawnRadius), Random.Range(-spawnRadius, spawnRadius), 0), Quaternion.identity); } } } | cs |
결과