123456789101112131415161718192021222324252627282930313233343536373839 |
- using System;
- using System.Collections;
- using System.Collections.Generic;
- using UnityEngine;
- public class teleport : MonoBehaviour
- {
- public GameObject player;
- public GameObject tp;
- private teleport nextTP;
- public bool isTeleport=false;
- public bool isTrap = false;
- void Start()
- {
- nextTP = tp.GetComponent<teleport>();
- }
-
-
- void OnTriggerEnter2D(Collider2D collision)
- {
- if (collision.gameObject.tag =="Player" && isTeleport)
- {
- isTeleport = false;
- StartCoroutine(Delay());
- }
- else if(isTrap)
- {
-
- }
- }
- private IEnumerator Delay()
- {
- player.transform.position = tp.transform.position;
- yield return new WaitForSeconds(10);
- nextTP.isTeleport = true;
- }
- }
|