Skip to content

Instantly share code, notes, and snippets.

@Yazir

Yazir/c# Secret

Created May 1, 2019 14:44
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Yazir/2fafdc73e6d765363dfe7635cbe6a530 to your computer and use it in GitHub Desktop.
Save Yazir/2fafdc73e6d765363dfe7635cbe6a530 to your computer and use it in GitHub Desktop.
Tweens problem
private void Destructible_OnDeath(GameObject source)
{
transform.parent = GameManager.Misc.transform;
Vector3 initialScale = transform.localScale;
Vector3 initialPosition = transform.position;
System.Action<ITween<float>> animUpdate = (t) =>
{
transform.localScale = initialScale * (1 + t.CurrentProgress * 0.5f);
baseRenderer.material.color = new Color(1, 1, 1, 1 * (1 - t.CurrentProgress));
transform.position = initialPosition + new Vector3(0, 0.35f, 0) * t.CurrentProgress;
};
System.Action<ITween<float>> animFinish = (t) => //This doesn't get called sometimes, leaving half transparent object in the scene
{
Destroy(gameObject);
};
gameObject.Tween("updatePos", 0f, 1f, 0.6f, TweenScaleFunctions.CubicEaseOut, animUpdate, animFinish);
//StartCoroutine("DestroyDelayed", 0.65f);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment