Object will not move when I use transform.position
I am trying to teleport a player from one platform to another. But for some reason the player does not move at all. When I print out the position right after I set it in code it is correct but as soon as the next update cycle comes around it is back at the position it was before I tried to teleport. When playing the game the player does not move at all when I am trying to teleport.
void UpdateCurrentLevel()
{
this.transform.position = new Vector3(transform.position.x,
levelManager.UpdateCurrentLevel().position.y + 1,
transform.position.z);
}
public Transform UpdateCurrentLevel()
{
currentLevel = levels[ChooseLevel()];
return currentLevel;
}
Answer by Triggerly · Jan 01, 2020 at 11:23 PM
Just do
this.transform.position = new Vector3(0, 0, 0);
Replace 0s with your coordinates
Does not work. Even when I manually just tell it to go to (0, 0, 0) or any other cordinate nothing happens.
maybe get rid of "this"? I'm not too sure it works for me
Your answer
![](https://koobas.hobune.stream/wayback/20220612220908im_/https://answers.unity.com/themes/thub/images/avi.jpg)
Follow this Question
Related Questions
How to check if transform.position reaches target.position? 2 Answers
What is the result of adding transform.position and transform.right? 1 Answer
Why Can't I get 2D object to Move? 1 Answer
how do i instantiate multiple object object with line change with for loop. 1 Answer
How do I move the object up when the another object gets on it 0 Answers