public IEnumerator Animation(GameObject g, GameObject attacked, CardState cardState) { isAnimating = true; Sprite newSprite = Resources.Load <Sprite>(cardState.GetSpriteString());//gameObject.transform.GetChild(0).GetComponent<SpriteRenderer>().sprite;//Resources.Load<Sprite>(cardState.GetSpriteString()); GameObject animated = new GameObject(); SpriteRenderer renderer = animated.AddComponent <SpriteRenderer>(); renderer.sprite = newSprite; renderer.sortingLayerName = "ArrowLayer"; animated.transform.SetParent(gameObject.transform); GameController gC = GameController.GetGameController(); animated.transform.position = g.transform.position; if (g.transform.position.x > attacked.transform.position.x) { animated.transform.Rotate(new Vector3(0, 180, 0)); } animated.GetComponent <SpriteRenderer>().sortingLayerName = "EntityLayer"; StartCoroutine(AnimateAttack(animated, animated.transform.position, attacked.transform.position, 50)); animateState = true; while (animateState) { yield return(null); } Destroy(animated); StartCoroutine(flash(attacked)); }