- Home /
Don't know why this script doesn't work.
Hey, so I'm trying to make a 3D base builder prototype and right know I'm working on my camera. What I'm trying to do is have this gameobject move with the mouse but at a certain Y position, and this is the script I'm trying to make, taking two Vector3s, the first one following the mouse position around the screen, which works, and then I want to take that same Vector and make it a new one with a different Y position, but I don't know why it doesn't work. Any help is appreciated!
void Update() { Vector3 mousePos = Input.mousePosition; Vector3 finalPos = new Vector3 (mousePos.transform.position.x, -2643.62 - mousePos.transform.position.y, mousePos.transform.position.z); }
Answer by Acdia · Jul 20, 2020 at 04:14 PM
A Vector3 is used like position. So you don't need to write mousePos.transform.position.x
but mousePos.x
.