- Home /
Question by
keszotrab · Mar 03, 2018 at 07:07 PM ·
mousepositioncamera.main
Object not following mouse. ,Object not following mouse in 2d game.
So i tried using "Camera.main.ScreenToWorldPoint(Input.mousePosition)" but the object was all the time in the center of the camera. I've watched couple videos, guides, etc. and everyone had Camera.main thing working corectly, i did exactly the same things but it wasn't working. So i tried just "Input(MousePosition)" instead, now it's moving with mouse but it still isn't in the mouse position. it's like half a screen diagonally after i divided it by 100. Help please.
// Use this for initialization
void Start () {
}
// Update is called once per frame
void Update () {
Vector3 temp =(Input.mousePosition);
temp.z = 0f;
transform.position = temp/100;
}
Comment
Your answer
