how to teleport a player in unity 2d without transform code example
Example: unity 2d teleport script
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class Teleportation : MonoBehaviour {
public GameObject Portal;
public GameObject Player;
void Start () {
}
void Update () {
}
public void OnTriggerEnter2D(Collider2D other)
{
if (other.gameObject.tag == "Player")
{
StartCoroutine (Teleport ());
}
}
IEnumerator Teleport()
{
yield return new WaitForSeconds (0.5f);
Player.transform.position = new Vector2 (Portal.transform.position.x, Portal.transform.position.y);
}
}