public IEnumerator AttachToPlayer(AttachPoint attachPoint) { float lerpTime = 0.15f; float timer = 0; float perc; Vector2 endPos = attachPoint.FreeAttachPoint(this); yAttachModifier = endPos.y - attachPoint.transform.position.y; Vector2 startPos = transform.position; sprite.sortingOrder--; while (timer <= lerpTime) { timer += Time.deltaTime; perc = timer / lerpTime; transform.position = Vector2.Lerp(startPos, endPos, perc); yield return(null); } pointAttachedTo = attachPoint; yield return(null); }