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,
}
}