so I made a interact script that when you press E will with in a box collider of the set object it triggers a script and teleports my player but nothing happens
Interact script :
public float interactDistance = 5f;
void Update()
{
if (Input.GetKeyDown(KeyCode.E))
{
Ray ray = new Ray(transform.position, transform.forward);
RaycastHit hit;
if (Physics.Raycast(ray, out hit, interactDistance))
{
if (hit.collider.CompareTag("portal"))
{
hit.collider.transform.GetComponent<TeleScript>().UseTele();
}
}
}
}
Teleport script:
public GameObject player;
public void UseTele()
{
player.transform.position = new Vector3(5.08f, 1.01f, -19.65f);
Debug.Log("TELEPORT");
}