I’m trying to make an empty object with a Box Collider 2D object attached teleport to player to specific coordinates when the player collides with it. When the main character object called DirtGuyAlpha collides with the Box Collider 2D nothing happens. Please help me.
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class SceneTransition : MonoBehaviour
{
// Start is called before the first frame update
void Start()
{
}
// Update is called once per frame
void Update()
{
}
void OnCollisionEnter(Collision collision)
{
if (gameObject.CompareTag("DirtGuyAlpha"))
{
GameObject player = GameObject.FindGameObjectWithTag("DirtGuyAlpha");
player.transform.Translate(-10, -26, 0);
}
}
}