So I have this ship sprite and I’m trying to get it to move to the position of the mouse when I click. The problem I’m having is that Input.mousePosition returns the global position (exact coordinates of the mouse in the scren) like (1280;502) but when I try to make the ship move to that position by doing transform.position = Input.mousePosition the ships goes off screen as it appairs that transform.position uses some sort of relative position.
target = Input.mousePosition;
transform.position = target; //Anything bigger than 10 will make the ship go off screen
Thanks, I used: Vector2 mousePos = Input.mousePosition; Vector2 wantedPos = Camera.main.ScreenToWorldPoint(new Vector2 (mousePos.x, mousePos.y)); transform.position = wantedPos;
– Mr.Z