So, I am trying to make it so that on contact with this boxcollider 2d, the player warps to a new zone. It is a topdown game so gravity and stuff is not an issue, and the character does have a collider as well. Also, is trigger is checked off but the character just goes through the collider and never warps. Here is my code.
using UnityEngine;
using System.Collections;
public class Warp : MonoBehaviour {
public Transform warpTarget;
void OnTriggerEnter2d(Collider2D other) {
Debug.Log("An object collided.");
other.gameObject.transform.position = warpTarget.position;
Camera.main.transform.position = warpTarget.position;
}
}
↧