aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMikkel Bybjerg <mikkel.bybjerg@hotmail.com>2019-04-27 09:09:57 +0200
committerMikkel Bybjerg <mikkel.bybjerg@hotmail.com>2019-04-27 09:09:57 +0200
commit8a17cd03497a4037067f9c1714d69a8975090189 (patch)
tree19cc0fa832028f83da27e842b8dffc263b028117
parent8db39efb58e68f57404ec204f9dbe15e6157f1b0 (diff)
optimize dragon transformations
-rw-r--r--nGJ2019/Assets/Prefabs/dragon_particle.prefab6
-rw-r--r--nGJ2019/Assets/Scripts/DragonMovement.cs10
-rw-r--r--nGJ2019/Assets/Scripts/SwarmSystem.cs7
3 files changed, 14 insertions, 9 deletions
diff --git a/nGJ2019/Assets/Prefabs/dragon_particle.prefab b/nGJ2019/Assets/Prefabs/dragon_particle.prefab
index ebe8458..6d528a3 100644
--- a/nGJ2019/Assets/Prefabs/dragon_particle.prefab
+++ b/nGJ2019/Assets/Prefabs/dragon_particle.prefab
@@ -10,7 +10,7 @@ GameObject:
m_Component:
- component: {fileID: 7771521336157481751}
m_Layer: 0
- m_Name: GameObject
+ m_Name: dragon_particle
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
@@ -59,7 +59,7 @@ Transform:
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 3956812704593654807}
m_LocalRotation: {x: -0, y: -0, z: -0, w: 1}
- m_LocalPosition: {x: 0.896, y: 0, z: 0}
+ m_LocalPosition: {x: 0, y: 0, z: 0}
m_LocalScale: {x: 0.29556, y: 0.29556, z: 0.29556}
m_Children: []
m_Father: {fileID: 7771521336157481751}
@@ -205,7 +205,7 @@ PrefabInstance:
- target: {fileID: 7341443742164647049, guid: 594cdcc1eff6dcd439f373be7d777373,
type: 3}
propertyPath: m_LocalPosition.x
- value: 0.896
+ value: 0
objectReference: {fileID: 0}
- target: {fileID: 7341443742164647049, guid: 594cdcc1eff6dcd439f373be7d777373,
type: 3}
diff --git a/nGJ2019/Assets/Scripts/DragonMovement.cs b/nGJ2019/Assets/Scripts/DragonMovement.cs
index 64d7f21..04f1c3a 100644
--- a/nGJ2019/Assets/Scripts/DragonMovement.cs
+++ b/nGJ2019/Assets/Scripts/DragonMovement.cs
@@ -55,9 +55,9 @@ public class DragonMovement : MonoBehaviour
private IEnumerator transformSlim()
{
- while(state == State.slim && transform.localScale.y > 0.2f)
+ while(state == State.slim && swarm.Collapse < 0.8f)
{
- transform.localScale = new Vector3(transform.localScale.x, transform.localScale.y-0.03f, transform.localScale.z-0.03f);
+ swarm.Collapse += 0.05f;
yield return new WaitForSeconds(0.01f);
}
}
@@ -73,9 +73,9 @@ public class DragonMovement : MonoBehaviour
private IEnumerator transformAntiSlim()
{
- while(state == State.normal && transform.localScale.y < 1)
+ while(state == State.normal && swarm.Collapse > 0)
{
- transform.localScale = new Vector3(transform.localScale.x, transform.localScale.y+0.05f, transform.localScale.z+0.05f);
+ swarm.Collapse -= 0.07f;
yield return new WaitForSeconds(0.01f);
}
if(state == State.normal)
@@ -155,7 +155,7 @@ public class DragonMovement : MonoBehaviour
private void resetTurn()
{
- transform.localScale = Vector3.one;
+ swarm.Collapse = 0;
swarm.Noise = 0;
}
diff --git a/nGJ2019/Assets/Scripts/SwarmSystem.cs b/nGJ2019/Assets/Scripts/SwarmSystem.cs
index 9f19dd0..9658a92 100644
--- a/nGJ2019/Assets/Scripts/SwarmSystem.cs
+++ b/nGJ2019/Assets/Scripts/SwarmSystem.cs
@@ -26,6 +26,7 @@ public class SwarmSystem : MonoBehaviour
private List<List<int>> triGraph;
public float Noise {get; set;}
+ public float Collapse {get; set;}
private Mesh getCurrentMesh()
{
@@ -365,11 +366,15 @@ public class SwarmSystem : MonoBehaviour
Vector3 boneCenter = findBoneCenter(u, out boneDirec);
- anchors[u].position = boneCenter + (Quaternion.AngleAxis(1f, boneDirec) * (anchors[u].position - boneCenter));
+ anchors[u].position = boneCenter + (Quaternion.AngleAxis(3f, boneDirec) * (anchors[u].position - boneCenter));
anchors[u].position = meshIntersection(u, vertices, triangles, boneCenter);
unit.position = anchors[u].position + Noise*noiseDirecs[u];
+
+ Vector3 collapsedPos = Vector3.Project(unit.position - transform.position, Vector3.right) + transform.position;
+
+ unit.position = (1-Collapse)*unit.position + Collapse*collapsedPos;
}
}