IEnumerator Polishing() { Debug.Log("Polishing"); float counter = 0; Vector3 lastPos = transform.position; Vector3 lastAng = transform.eulerAngles; while (counter < 5) { if (detectKinematicMovement(lastPos, lastAng) && reset == false) { counter += Time.deltaTime; Smoke.transform.position = transform.position; Smoke.GetComponent <ParticleSystem>().Play(); } if (polishing == false) { yield break; } lastPos = transform.position; lastAng = transform.eulerAngles; yield return(null); } Debug.Log("Instantiated!!"); GameObject blade = database.Craft(currentTarget.GetComponent <IngotProperties>()); if (blade != null) { Instantiate(blade, currentTarget.transform.position, Quaternion.identity); Destroy(currentTarget); } currentTarget = null; }