Question by
Beta4 · Apr 06, 2018 at 03:55 PM ·
movementtranform.position
Moving an Object with tranform.position?
So this is a question for education purposes. I know how move an object with transform.translate. I wanted to know if this could be accomplished with transform.position and if so how. I have created a script, but all it does is move ever so slightly in the direction and back to the center and no matter where I place the object in the scene it always starts in the middle of the screen. I have tried transform.localPosition and still goes to the center of the screen. Here is my code. Hope someone out there can help me with my problem.
void Update() { speed = 10f;
x = Input.GetAxis("Horizontal") * speed * Time.deltaTime;
y = Input.GetAxis("Vertical") * speed * Time.deltaTime;
transform.localPosition = new Vector3(x, y, 0f);
}
Comment
Your answer
![](https://koobas.hobune.stream/wayback/20220612160216im_/https://answers.unity.com/themes/thub/images/avi.jpg)
Follow this Question
Related Questions
Character movement 0 Answers
FPS movement with momentum 1 Answer