diff options
author | chai <215380520@qq.com> | 2024-03-13 11:00:58 +0800 |
---|---|---|
committer | chai <215380520@qq.com> | 2024-03-13 11:00:58 +0800 |
commit | 6ce8b9e22fc13be34b442c7b6af48b42cd44275a (patch) | |
tree | b38119d2acf0a982cb67e381f146924b9bfc3b3f /ScreenShakeByCollision.cs |
+init
Diffstat (limited to 'ScreenShakeByCollision.cs')
-rw-r--r-- | ScreenShakeByCollision.cs | 34 |
1 files changed, 34 insertions, 0 deletions
diff --git a/ScreenShakeByCollision.cs b/ScreenShakeByCollision.cs new file mode 100644 index 0000000..14cd1ca --- /dev/null +++ b/ScreenShakeByCollision.cs @@ -0,0 +1,34 @@ +using UnityEngine; + +public class ScreenShakeByCollision : MonoBehaviour +{ + private WobbleShake shake; + + private void Start() + { + shake = base.transform.root.GetComponentInChildren<WobbleShake>(); + } + + private void Update() + { + } + + private void OnCollisionEnter(Collision collision) + { + Collide(collision); + shake.AddShakeWorld(collision.relativeVelocity * -0.08f, 0.9f); + } + + private void OnCollisionStay(Collision collision) + { + Collide(collision); + shake.AddShakeWorld(collision.relativeVelocity * -0.01f, 0.9f); + } + + private void Collide(Collision collision) + { + if (!(collision.transform.root == base.transform.root)) + { + } + } +} |