Last active
July 7, 2018 19:26
-
-
Save EliCDavis/5ce23ddb569fbf607def1cf84ac38c62 to your computer and use it in GitHub Desktop.
a code example for https://medium.com/scry-llc/applying-explosion-knock-back-1f394f7160e8
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
private void Close() | |
{ | |
ParticleSystem particleSystem = GetComponent<ParticleSystem>(); | |
particleSystem.Stop(); | |
Destroy(gameObject, particleSystem.main.startLifetime.constantMax); | |
StartCoroutine(FadeTime(particleSystem.main.startLifetime.constantMax)); | |
} | |
private System.Collections.IEnumerator FadeTime(float timeToFadeIt) | |
{ | |
float timeRemaining = timeToFadeIt; | |
while (timeRemaining > 0) | |
{ | |
audio.volume = timeRemaining / timeToFadeIt; | |
timeRemaining -= Time.deltaTime; | |
yield return null; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment