//Method is called by flying artifact picked up right before it destroys itself public void BestowFlyingCurse(Artifact artifact) { //print("new flying artifact" + transform.name); GameObject newFlyingArtifact = (Instantiate(flyingArtifactPrefab.gameObject, transform.position + new Vector3(0, 1, 0), transform.rotation)) as GameObject; newFlyingArtifact.GetComponent <FlyingArtifactScript>().SetTarget(transform); ArtifactScript.SetupArtifactObject(newFlyingArtifact, artifact); }
private IEnumerator ArtifactAnimation(Artifact artifact) { this.GetComponent <PlayerMovment>().enabled = false; this.GetComponent <CharacterController>().enabled = false; this.GetComponent <Rigidbody2D>().velocity = Vector2.zero; yield return(new WaitForSeconds(1f)); GameObject animArtifact = (Instantiate(new GameObject(), transform.position + new Vector3(0, 1, 0), transform.rotation)) as GameObject; animArtifact.AddComponent <SpriteRenderer>(); ArtifactScript.SetupArtifactObject(animArtifact, artifact); animArtifact.GetComponent <SpriteRenderer>().sortingOrder = 2; yield return(new WaitForSeconds(1f)); myArtifacts.Add(artifact); this.GetComponent <PlayerMovment>().enabled = true; this.GetComponent <CharacterController>().enabled = true; Destroy(animArtifact); }