Teleporter Not Working

I’m very new to unity and I’m just trying to make a simple teleporter to move the player character from one part of the level to another. I’ve turned a cube into a trigger, placed it where I want it, and attached a script to it which should make the player’s transform.position the same as the target’s transform.position. However this is not working for some reason. Instead of teleporting, what happens is the player appears to get pulled into the trigger when they touch it.

Here’s the code for the trigger:

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

public class Teleporting : MonoBehaviour
{
    public Transform teleportTarget;
    public GameObject player;
    private void OnTriggerEnter(Collider collider)
    {
        player.transform.position = teleportTarget.transform.position;
    }
}

The Gameobject, player gets set to the player and the teleportTarget gets set to the empty.

Thanks in advance

Hey,

The code you posted works for me, you may want to check if the teleportTarget is actually at a different location than the trigger object. You should also add a Debug.Log(“Triggered!”) line to your OnTriggerEnter, just to make sure that it’s actually being called.

Good Luck!

1 Like

I used this shader graph I created for teleporting it was nice effect but I never could use it with my game only in another project. GitHub - chocolade1972/Dissolve-Shader-Graph: Dissolve Shader Graph