Teleport Script by KeyDown for fast Level testing

Hi!
I have a problem with a C# Script which is made for faster level testing.


How it works:

You can make multiple empty GameObjects(Teleport points for now) and place them freely around the map and attaching the below script to them.
After that you can choose which button should Teleport the Player to which GameObject.


My problem is very weird because the Script is works under 2017.2.5 just fine, but on 2019.2.5 when I try to teleport I instantly get back where I was.

I searched a lot but couldn’t figured out myself, if you have any idea please share, I would appreciate a lot!

UPDATE:

I think I found where I should look into, I suppose the movement controller what I use Updates more frequently?(I’m not a coder) and rewrites this script all the time ?
If I change the Update method to FixedUpdate, the code is working but only for one teleport point
so the next step is how I should modify the code to enable the other teleport points too ?

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

public class TestTeleportPoint : MonoBehaviour {
    
    [Header("Alpha is numbers on keyboard and numpad are numbers on the numpad")]
    [SerializeField]
    private Keys button;

	
	// Update is called once per frame
	void Update () {
        if (Input.GetKeyDown((KeyCode)button))
        {
            GameObject.FindWithTag("Player").transform.position = transform.position;
        }
	}

    private enum Keys
    {
        
        Alpha1 = KeyCode.Alpha1,
        Alpha2 = KeyCode.Alpha2,
        Alpha3 = KeyCode.Alpha3,
        Alpha4 = KeyCode.Alpha4,
        Alpha5 = KeyCode.Alpha5,
        Alpha6 = KeyCode.Alpha6,
        Alpha7 = KeyCode.Alpha7,
        Alpha8 = KeyCode.Alpha8,
        Alpha9 = KeyCode.Alpha9,
        Alpha0 = KeyCode.Alpha0,
        Numpad0 = KeyCode.Keypad0,
        Numpad1 = KeyCode.Keypad1,
        Numpad2 = KeyCode.Keypad2,
        Numpad3 = KeyCode.Keypad3,
        Numpad4 = KeyCode.Keypad4,
        Numpad5 = KeyCode.Keypad5,
        Numpad6 = KeyCode.Keypad6,
        Numpad7 = KeyCode.Keypad7,
        Numpad8 = KeyCode.Keypad8,
        Numpad9 = KeyCode.Keypad9,
    }
}

@Atis
Instead of setting the player’s position to transform.position, create a new Vector3 based on transform.position. It would look like this:

GameObject.FindWithTag("Player").transform.position = new Vector3(transform.position.x,transform.position.y,transform.position.z);

Hey everyone, I fixed this problem with a workaround and that is to:

  1. disable the player character controller,

  2. apply the transform modifier to the player Transform, and

  3. enable the player character controller.

    CharacterController player = FindObjectOfType();
    player.enabled = false;
    player.transform.SetPositionAndRotation(transform.position,transform.rotation);
    player.enabled = true;

Apparently, in 2017 the character controller doesn’t force the player transform values back to its current position whereas in 2019 it does that now when you apply a transform value to a GameObject with a character controller component and calling CharacterController.Move in the Update() loop.