Hi there
i have a 3d object (clock) that can be draged around inside an ortographic camera. I use this line of code inside the OnMouseDrag() to place the camera and it works perfectly:
this.transform.position = Cam.ScreenToWorldPoint(new Vector3(Input.mousePosition.x, Input.mousePosition.y, 5));
My camera has a script that allows it to be dragged around like a floating window and lastely each clock has a gui label that indicates it’s time.
The problem is that, when I drag a clock, the label stays exactly in position, but when I drag the “window” around, the label stays perfect on the x axis, but goes out on the y axis. Here is the code for that line:
Vector2 labelPos = Cam.WorldToScreenPoint(new Vector2(this.transform.position.x, this.transform.position.y * -1));
The above script is linked to the clock object. Why would the label stay in position when the clock itself is dragged, but when the camera moves, it goes out?
Thanks in advance