diff options
author | miakata <miakata@gmail.com> | 2019-04-28 02:08:47 +0200 |
---|---|---|
committer | miakata <miakata@gmail.com> | 2019-04-28 02:08:47 +0200 |
commit | b0a8bf29889bec24153abbd6f39ad1a0f5662393 (patch) | |
tree | bf742b1078b59712235535f62ee2402d9d4e294e /nGJ2019/Assets/Scripts | |
parent | c9592befb156b0528fec0000613c2dd73fe90af8 (diff) | |
parent | 1ed8a90dc94bedb19039ee1777c12b6a731cf710 (diff) |
Merge branch 'master' of https://github.com/marcinzelent/ngj2019
Diffstat (limited to 'nGJ2019/Assets/Scripts')
-rw-r--r-- | nGJ2019/Assets/Scripts/ObstacleSpawner.cs | 4 | ||||
-rw-r--r-- | nGJ2019/Assets/Scripts/RockJaws.cs | 15 |
2 files changed, 11 insertions, 8 deletions
diff --git a/nGJ2019/Assets/Scripts/ObstacleSpawner.cs b/nGJ2019/Assets/Scripts/ObstacleSpawner.cs index 1615714..4c4028f 100644 --- a/nGJ2019/Assets/Scripts/ObstacleSpawner.cs +++ b/nGJ2019/Assets/Scripts/ObstacleSpawner.cs @@ -1,4 +1,4 @@ -using System.Collections; +using System.Collections; using System.Collections.Generic; using UnityEngine; @@ -50,7 +50,7 @@ public class ObstacleSpawner : MonoBehaviour timeline.Add(0, new Vector3(0, 2.75f, 0), ObstacleType.rockTop); timeline.Add(6, new Vector3(0, -2, 0), ObstacleType.rockBottom); timeline.Add(12, new Vector3(0, 0, 0), ObstacleType.narrowPassage); - timeline.Add(20, new Vector3(0, 0, 2), ObstacleType.rockJaws); + timeline.Add(20, new Vector3(0, -2.5f, 2), ObstacleType.rockJaws); timeline.Add(25, new Vector3(0, 0.5f, 3), ObstacleType.net); timeline.OnSpawnEvent += spawnOnEvent; diff --git a/nGJ2019/Assets/Scripts/RockJaws.cs b/nGJ2019/Assets/Scripts/RockJaws.cs index a161dfe..874d6d3 100644 --- a/nGJ2019/Assets/Scripts/RockJaws.cs +++ b/nGJ2019/Assets/Scripts/RockJaws.cs @@ -23,15 +23,18 @@ public class RockJaws : MonoBehaviour void FixedUpdate()
{
- if (TopJaw.localPosition.y < BottomJaw.localPosition.y) reverse = true;
- else if(TopJaw.localPosition.y > initialTopJawY) reverse = false;
+ var topJawHeight= TopJaw.GetComponent<MeshRenderer>().bounds.size.y;
+ var bottomJawHeight= BottomJaw.GetComponent<MeshRenderer>().bounds.size.y;
+
+ if (TopJaw.localPosition.y - topJawHeight / 2 < BottomJaw.localPosition.y + bottomJawHeight / 2) reverse = true;
+ else if(TopJaw.localPosition.y > initialTopJawY) reverse = false;
if (!reverse) {
- TopJaw.Translate(0, -0.01f * Speed, 0);
- BottomJaw.Translate(0, 0.01f * Speed, 0);
+ TopJaw.Translate(0, -0.01f * Speed, 0, Space.World);
+ BottomJaw.Translate(0, 0.01f * Speed, 0, Space.World);
} else {
- TopJaw.Translate(0, 0.01f * Speed, 0);
- BottomJaw.Translate(0, -0.01f * Speed, 0);
+ TopJaw.Translate(0, 0.01f * Speed, 0, Space.World);
+ BottomJaw.Translate(0, -0.01f * Speed, 0, Space.World);
}
}
}
|