title: Unity can only teleport another gameObject on certain angles and positions
body: <p>I'm trying to make a portal, but I don't understand why the code:</p>
  
  <pre><code>playerControl.transform.position = new Vector3(destination.position.x, destination.position.y, destination.position.z);
  </code></pre>
  
  <p>only works on certain positions and angles.</p>
  
  <p>This is the set up for the code</p>
  
  <pre><code>    public class Teleport : Interactable
  {
      public Transform destination;
      private GameObject playerControl;
      private PortalAnimationController portalController;
  
      // Start is called before the first frame update
      void Start()
      {//get the player information
          playerControl = PlayerManager.instance.player;
          portalController = PortalAnimationController.instance;
      }
  
  
      public override void interact()
      {
          //base.interact();
          //run the teleport method
  
          StartCoroutine("teleport");
  
          //Debug.Log(playerControl.GetInstanceID());
  
      }
  
  
      /*
       1. trigger the panel
       2. stop the time
       3. teleport the player
       */
      private IEnumerator teleport()
      {
          Time.timeScale = 0f;//stop the time
          portalController.fadeOut();
          //wait for seconds realtime can avoid stopping when timescale is 0
          yield return new WaitForSecondsRealtime(portalController.duration);//wait for the transition
          Debug.Log("wait finish");
          //after the the wait
          Debug.Log(playerControl.transform.position + "before");
          playerControl.transform.position = new Vector3(destination.position.x, destination.position.y, destination.position.z);
          if(playerControl.transform.position!= destination.position)
          {
              Debug.Log(playerControl.transform.position);
          }
          else
          {
              Debug.Log(playerControl.transform.position+"pass");
          }
          portalController.fadeOut();
          Time.timeScale = 1f;
      }
  }
  </code></pre>
  
  <p>The interactable class 
  only contains a "public virtual void interact()" method for teleport to override it.
  The way to trigger is through the code below:</p>
  
  <pre><code>void Update()
      {
          RaycastHit hit;
          if (Input.GetButtonDown("Interact"))
          {
              if (Physics.Raycast(cam.transform.position, cam.transform.forward, out hit, interactableRange))
              {
                  Interactable interactable = hit.collider.GetComponent&lt;Interactable&gt;();
                  //if the player is looking at the interactable
                  //Debug.Log("Interact with " + hit.transform.name);
                  if (interactable != null)
                  {
                      //highlight the object
                      interactable.interact();
                      //if player press the interact key, then pick it up
                      Debug.Log("Interact with " + hit.transform.name);
  
  
                  }
              }
          }
      }
  </code></pre>
  
  <p>It shoots a ray when the e key is pressed, then hit a collider box to retrieve the interactable component and call the interact() immediately.</p>
  
  <p>I have tested it hundreds of times, and there are only 3 results. 
  1. player actually get teleported.(success)
  2. player flashes to the destination in 1 frame then back to where it was.(failed)
  3. player does not move at all.(failed)</p>
  
  <p><a href="https://youtu.be/HfMUwWfnZOs" rel="nofollow noreferrer">video link</a></p>