- Home /
The question is answered.
Vector 3 - move on only one axis
Hi! I want to move my gameobject (by script) on ONLY ONE axis. I want use to this Vector3, but I don't know how to move my object in only Z axis. My gameobject fall in the game, so when i use
player.transform.position = new Vector3(0, 0, 15);
my gameobject return to 0 in Y axis. Any ideas?
I forgot: I want to move my object on tracks, like in Subway Surfers. Sorry for bad English.
O$$anonymous$$. Problem was fixed.
float X = player.transform.position.x; float Y = player.transform.position.y;
player.transform.position = new Vector3(X, Y, 15);
Follow this Question
Related Questions
How can I call this player transform.position code once, then stop? 2 Answers
Moving an Object - The right way. 2D 1 Answer
follow along the XZ plane? 0 Answers
move a gameobject to left/right while going up 1 Answer
Rigidbody.MovePosition() moves only in the GLOBAL z axis (forward and backward) 1 Answer