diff options
Diffstat (limited to 'GameCode/ObjectShake.cs')
-rw-r--r-- | GameCode/ObjectShake.cs | 29 |
1 files changed, 29 insertions, 0 deletions
diff --git a/GameCode/ObjectShake.cs b/GameCode/ObjectShake.cs new file mode 100644 index 0000000..f4e8059 --- /dev/null +++ b/GameCode/ObjectShake.cs @@ -0,0 +1,29 @@ +using UnityEngine; + +public class ObjectShake : MonoBehaviour +{ + public float globalMultiplier = 1f; + + public float interval = 0.1f; + + public float movementMultiplier = 1f; + + public float rotationMultiplier = 1f; + + private float counter; + + private void Start() + { + } + + private void Update() + { + counter += TimeHandler.deltaTime; + if (counter > interval) + { + base.transform.localPosition = Random.insideUnitCircle * movementMultiplier * globalMultiplier * 0.1f; + base.transform.localEulerAngles = new Vector3(base.transform.localEulerAngles.x, base.transform.localEulerAngles.y, (float)Random.Range(-10, 10) * globalMultiplier * rotationMultiplier); + counter = 0f; + } + } +} |