public void dropSpell(SpellBook dropSpell, Vector3 originPos) // drop the spellbook { Debug.Log("Dropped Spell"); // unlink spellbook from player if (dropSpell.owner == this.GetComponent <SpellCaster>()) { dropSpell.owner = null; } if (spellsInventory.Contains(dropSpell)) { spellsInventory.Remove(dropSpell); } // update current held // updateCurrentHeld(); dropSpell.Activate(); dropSpell.transform.parent = null; dropSpell.transform.position = transform.position; // dropSpell.Drop(originPos); // dropSpell.Die(); // visualize dropping book StartCoroutine(dropSpellProcess(dropSpell, originPos)); }
public void dropSpell(SpellBook dropSpell, Vector3 originPos) { if (dropSpell.owner == this.GetComponent <SpellCaster>()) { dropSpell.owner = null; } dropSpell.Activate(); dropSpell.transform.parent = null; dropSpell.transform.position = transform.position; }
IEnumerator dropSpellProcess(SpellBook dropSpell, Vector3 originPos) // visualize dropping the book { // dropSpell.dead = true; dropSpell.Activate(); // turn on the book dropSpell.transform.parent = null; Vector3 startPos = dropSpell.transform.position; while (!dropSpell.dead && Vector3.Distance(dropSpell.transform.position, originPos) > 0.2f) { dropSpell.transform.position = Vector3.Lerp(dropSpell.transform.position, originPos, Time.deltaTime / spellPickUpSpeed); // shift book to position yield return(new WaitForEndOfFrame()); } updateCurrentHeld(); }