- Home /
Why won't my teleport script teleport the gameObject/Character to the right position?
I have a teleport script. And it works.. But it doesnt completely work. As in it doesnt teleport the gameObject/Player to the right position. i think its changing the position from the current position? as in like adding or subtracting from the coords and not completely making new ones?. the script is
using System.Collections; using System.Collections.Generic; using UnityEngine; public class TeleportBackUp : MonoBehaviour { // Start is called before the first frame update void Start() { } // Update is called once per frame void OnCollisionEnter(Collision col) { if (col.gameObject.name == ("Teleport")) { transform.Translate(13.42f, 0.036f, -4.93f); } } }
i think its something to do with the transform.Translate(13.42f, 0.036f, -4.93f);
part. with the f's at the end of them. but i dont know how else to do it Can someone please help me out?
Answer by xxmariofer · Dec 03, 2020 at 01:03 PM
try changing
transform.Translate(13.42f, 0.036f, -4.93f);
t
transform.position = new Vector3(13.42f, 0.036f, -4.93f);