Skip to content

Instantly share code, notes, and snippets.

@GeorgiyRyaposov
Last active March 25, 2017 10:35
Show Gist options
  • Save GeorgiyRyaposov/8d4b424fd60888c56d2cc824de44fb78 to your computer and use it in GitHub Desktop.
Save GeorgiyRyaposov/8d4b424fd60888c56d2cc824de44fb78 to your computer and use it in GitHub Desktop.
Shake routine
public Vector3 shakePower = new Vector3(0.03f, 0.03f, 0.03f);
public float shakeDuration = 1f;
private IEnumerator ShakeRoutine()
{
for (var t = 0f; t < shakeDuration; t += Time.unscaledDeltaTime)
{
var offset = transform.rotation * Vector3.Scale(Random.onUnitSphere, shakePower);
transform.position += offset;
yield return null;
transform.position -= offset;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment