note i’m new to coding so…i know almost nothing
First of all you should answer the Question : How the Teleport should be triggered ?
If you wan’t to teleport the Player in every State of the game by pressing a specific key your code look like this :
private Transform PlayerTransform;
public Transform TeleportGoal;
//-------------------------------
void Start ()
{
PlayerTransform = Gameobject.Find("Player").transform;
// Reference the Player's Transform Component
}
//-------------------------------
void Update ()
{
if(Input.GetKeyDown(KeyCode.E))
{
PlayerTransform.position = TeleportGoal.position
}
}
If you want to teleport the Player, when he moves into a Trigger you can use :
void OnTriggerEnter ()
{
PlayerTransform.position = TeleportGoal.position
}
or :
void OnTriggerStay ()
{
if(Input.GetKeyDown(KeyCode.E))
{
PlayerTransform.position = TeleportGoal.position
}
}
Dont forget to add a collider to the gameobject where you put this script on and check the box “isTrigger”;
I hope I could help
What do you mean by “teleport”?
If you want to go to the position of the empty object:
player.transform.position = emptyObject.transform.position;
If you want to make the player a child of the empty object:
player.transform.SetParent(emptyObject.transform);