how to teleport an object,want to teleport an object but it won't work
i want to teleport my player (objToTP) to a another object (tplocation), i currently have this: objToTP.transform.position = tplocation.transform.position ;
but it doesn,t work, variables are assigned and the function executes, no error message in the console,ok, so i want to tp my player when he touches a trigger, i currently have this:
objToTP.transform.position = tplocation.transform.position ;
both are assigned but nothing works, the function is executing (checked that with debug.log) anyone knows what
Answer by ray2yar · Jan 26, 2019 at 06:08 PM
Try Debug.Log(objToTP.name); to make sure your moving the object you think..... maybe also try Debug.Log(tplocation.transform.position.ToString()); to make sure your location is what you think it is....
Other than that your code seems sound to me.
@ray2yar ok, thx, the objToTP should be fine, cause i already tried debug.log(objToTP.transform.position) to make sure that it was getting that right and it did indeed output the position of my player, i'll try doing what you say, but i think it's unlikely to be an issue with the location of the tplocation as the player doesn't teleport at all
Often in these cases it's something simple that is over looked. It's is it possible you're moving a child object and not the parent? Another way to debug this is to go into the scene view after an attempted teleport and look to see if anything is there at all- including empties. We know you actually are moving SO$$anonymous$$ETHING- otherwise you'd be thrown an error.
Your answer
Follow this Question
Related Questions
need help teleporting an object 0 Answers
Script for teleport on collision? 2 Answers
Teleport script help! 1 Answer
Can't make player character teleport from one side of screen to another. 1 Answer
Teleport Script 3 Answers