Sunday, 9 October 2016

teleporting Player

//value....
public GameObject player;
public Transform destination;
public GameObject blankpage;
public GameObject Teleporting_ParticalEffect;
// Use this for initialization
void Start () {

player = GameObject.FindGameObjectWithTag ("Player");
}

//transform right to left and left to right....
void OnCollisionStay2D(Collision2D other){
if (other.gameObject.tag == "Player" || other.gameObject.tag == "Shield") {

StartCoroutine(Examples());

}

}
IEnumerator Example() {
yield return new WaitForSeconds(3);
player.transform.position = destination.transform.position;
}
IEnumerator Examples() {
Instantiate(Teleporting_ParticalEffect, transform.position, Quaternion.identity);
yield return new WaitForSeconds(1);
blankpage.SetActive (true);
StartCoroutine(Example());
StartCoroutine(Example1());

}
IEnumerator Example1() {
yield return new WaitForSeconds(6);
blankpage.SetActive (false);
}

No comments:

Post a Comment