diff options
author | marcinzelent <zelent.marcin@gmail.com> | 2019-04-28 01:00:52 +0200 |
---|---|---|
committer | marcinzelent <zelent.marcin@gmail.com> | 2019-04-28 01:00:52 +0200 |
commit | 790e527dc4433beadf12abaee618da9650699a82 (patch) | |
tree | 1436e8d0c6acff5de1494c90da42cc06aa92ca3a /nGJ2019/Assets/Scripts | |
parent | 563f06e6caf98b6112952fe1065ddeabc327ea83 (diff) |
Updated rock jaws model
Diffstat (limited to 'nGJ2019/Assets/Scripts')
-rw-r--r-- | nGJ2019/Assets/Scripts/RockJaws.cs | 15 |
1 files changed, 9 insertions, 6 deletions
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);
}
}
}
|