2D Door interact (teleporting)

Hello, I am trying to make a teleporter so that when I interact with the door I can teleport to another part of my scene. I have followed multiple tutorials and it will not work. I really need help as none of the tutorials are working. I have also researched on reddit, here, and other forums. I have box collider 2d is trigger on and also have downloaded the latest input system. Here is the code I currently am using, any help would be greatly appreciated! :)

using System.Collections;
using System.Collections.Generic;
using System;
using UnityEngine;

public class DoorUniversal : MonoBehaviour {

public GameObject PlayerChar;
public bool InsideTriggerArea = false;
public GameObject Door;
public GameObject TargetDoor;

void OnTriggerEnter2D(Collider2D Door)
{
Debug.Log("Entered");
InsideTriggerArea = true;
}

void OnTriggerStay2D(Collider2D Door)
{
Debug.Log("Stayed");
InsideTriggerArea = true;

if (Input.GetButtonDown("Interact"))
{

Debug.Log("Using Door");
PlayerChar.transform.position = new Vector4(TargetDoor.transform.position.x, TargetDoor.transform.position.y, TargetDoor.transform.position.z);

}
}

void OnTriggerExit2D(Collider2D Door)
{
Debug.Log("Left");
InsideTriggerArea = false;
}

void FixedUpdate()
{

}
}

This is what I have for the input interact: 9301745--1302989--upload_2023-9-13_7-35-49.png

This is my inspector tab for the first portal: 9301745--1302992--upload_2023-9-13_7-38-8.png

I also get no message in my portal unless I make the box collider bigger then the map and it overlaps everything else I have. But then I only get to the Debug.Log("Stayed") part of my script and it does not get further. When I leave though I do get the Debug.Log("Left") part. For some reason it is not reading my
if (Input.GetButtonDown("Interact"))
{

Debug.Log("Using Door");
PlayerChar.transform.position = new Vector4(TargetDoor.transform.position.x, TargetDoor.transform.position.y, TargetDoor.transform.position.z);

}

Again though this is only if I have the collision bigger then the map. Again any help would be helpful, thank you! 9301745--1302989--upload_2023-9-13_7-35-49.png

FYI: Here's how to post code on the forum so it's readable: https://discussions.unity.com/t/481379

Physics doesn't run per-frame which is where you should be reading input. If you've followed any tutorials you should've seen this mentioned. Asking if a key was pressed this frame should be done per-frame, not during a physics callback which happens (by default) during the FixedUpdate.

You also should never, ever modify the Transform when using 2D physics. The only thing that moves in physics is a Rigidbody2D so you should use its API to cause movement and there are three body-types to choose from. I won't go into further detail because that's what tutorials are for TBH.

I really don't understand why a "Door" would be repositioned though, surely it'd be a "player". Also, why are you using Vector4 for position, it's a Vector3. Seems like there's a lot going wrong here. You also don't refer to the "Door" that hits the trigger, you always refer to the two things you reference in the script. To me, it just seems like there's some confusion here on your part or maybe just on my part understanding doors/portals and why they are "moving" at all.

You don't need to continue reasse

Here I tried updating my code to this from a different tutorial. And yes I am trying to move the player from one location to another not the door lol. But it still isnt working with this code either. I added a rigidbody 2D to the player and both doors/"portals."

using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class Portal : MonoBehaviour
{
   private Transform destination;

   public bool isMainHouse;
   public float distance = 0.2f;

   // Start is called before the first frame update
   void Start()
   {
    if (isMainHouse == false)
    {
        destination = GameObject.FindGameObjectWithTag("MainHouse").GetComponent<Transform>();
    }  else
    {
        destination = GameObject.FindGameObjectWithTag("InMainHouse").GetComponent<Transform>();
    }
   }

   /// <summary>
   /// Sent when another object enters a trigger collider attached to this
   /// object (2D physics only).
   /// </summary>
   /// <param name="other">The other Collider2D involved in this collision. </param>
   void OnTriggerEnter2D(Collider2D other)
   {
    if (Vector2.Distance(transform.position, other.transform.position) > distance)
    {
        other.transform.position = new Vector2 (destination.position.x, destination.position.y);
    }
   }
}