From 79feae7a03d06fbd845442c385c34ffebe70843e Mon Sep 17 00:00:00 2001 From: Mikkel Bybjerg Date: Sun, 28 Apr 2019 03:38:03 +0200 Subject: improved dragon and obstacle reaction correct --- nGJ2019/Assets/Scripts/SwarmSystem.cs | 30 +++++++++++++++++------------- 1 file changed, 17 insertions(+), 13 deletions(-) (limited to 'nGJ2019/Assets/Scripts/SwarmSystem.cs') diff --git a/nGJ2019/Assets/Scripts/SwarmSystem.cs b/nGJ2019/Assets/Scripts/SwarmSystem.cs index 9658a92..798cf13 100644 --- a/nGJ2019/Assets/Scripts/SwarmSystem.cs +++ b/nGJ2019/Assets/Scripts/SwarmSystem.cs @@ -6,8 +6,12 @@ public class SwarmSystem : MonoBehaviour public GameObject swarmPrefab; public GameObject anchorPrefab; public int size = 1; + public Vector3 collapseCenter; + + public SkinnedMeshRenderer meshRender; public bool showGuides = false; + public bool showMesh = false; private List units = new List(); private List anchors = new List(); @@ -20,8 +24,6 @@ public class SwarmSystem : MonoBehaviour private List boneCenterStarts = new List(); private List boneCenterDists = new List(); - private SkinnedMeshRenderer meshRender; - private List unitTris = new List(); private List> triGraph; @@ -334,8 +336,6 @@ public class SwarmSystem : MonoBehaviour void Start() { - meshRender = GetComponentInChildren(); - mapBones(); refreshMesh(); @@ -372,7 +372,9 @@ public class SwarmSystem : MonoBehaviour unit.position = anchors[u].position + Noise*noiseDirecs[u]; - Vector3 collapsedPos = Vector3.Project(unit.position - transform.position, Vector3.right) + transform.position; + Vector3 coll = transform.position + collapseCenter; + + Vector3 collapsedPos = Vector3.Project(unit.position - coll, Vector3.right)*0.3f + coll; unit.position = (1-Collapse)*unit.position + Collapse*collapsedPos; } @@ -382,8 +384,6 @@ public class SwarmSystem : MonoBehaviour { if(showGuides) { - meshRender = GetComponentInChildren(); - mapBones(); refreshMesh(); @@ -398,12 +398,13 @@ public class SwarmSystem : MonoBehaviour Mesh mesh = getCurrentMesh(); - for(int i=0; i