Skip to content

Instantly share code, notes, and snippets.

@Yazir Yazir/c# Secret
Created May 1, 2019

Embed
What would you like to do?
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
You can’t perform that action at this time.