transform.position transports me to the wrong position

Okay so when I use transform.position to move my player into a building, it moves me to coordinates that are either wrong or on a different terrain. And I know it isn’t because of scale or the parent not being at (0, 0, 0) because all the other trigger collisions in that group work. This one even works if I move it along the x-axis away from the door. But for some reason it just doesn’t work in that little area and I have no clue why. And it’s not a scripting error because all the others work! Any help is GREATLY appreciated! :slight_smile:

So please show us your script?

using UnityEngine;
using UnityEngine.UI;
using System.Collections;

public class SceneChange : MonoBehaviour {
 
    public Text pressE;
    public Collider Player;
    public string Scene;
    public bool Trigger;
    public Vector3 doorPosition;

    void Start ()
    {
        pressE.text = "";
        Trigger = false;
    }


    void OnTriggerEnter (Collider Player)
    {
        Trigger = true;
        pressE.text = "Press 'E' to Use";
    }

    void Update ()
    {
        if (Trigger == true)
        {
            if (Input.GetKeyDown ("e"))
            {
                Player.transform.position = (doorPosition);
            }
        }
    }

    void OnTriggerExit (Collider Player)
    {
        Trigger = false;
        pressE.text = "";
    }
}

Here ya go

Maybe your door transform’s pivot is offsetted or doorPosition doesn’t get set properly. Try having a Transform doorTransform variable instead of a Vector3 doorPosition and then set the position as follows:
Player.transform.position = doorTransform.position;
If that doesn’t work, try: Player.transform.parent = doorTransform; Player.transform.localPosition = Vector3.zero; and see where this get’s the player.

Try what Dreamteck said, and if that doest work just try a simple,

// This pops up in the console window.
Debug.Log(doorPosition);

In the script. Just run it by the numbers in your scene view. If you door position does not match, that is due to the origins of your door gameobject (It’s where you see the colored axis’s show up in the scene view) not matching up correctly.

To make a quick fix for THAT. You could create an empty GameObject, call it something like, DoorOrigins, and then just use the position of that (once you have parented it to the door, and placed it in a good position before parenting it) to make sure the player gets updated.