I have created multiple gameobjects in the scene with parent child relationship. When I move the camera with a joystick it moves around the node in an orbit. but when the camera moves vertically the 2D text on Node gameobject which focuses the camera by LookAround()
, it rotates 180 degrees. Which is in the opposite direction.
Asked
Active
Viewed 98 times
0

66Gramms
- 769
- 7
- 23

Aqib Ahmed
- 29
- 1
- 7
-
1Could you provide more details? What is this LookAround function, as i'm sure it is not a built in unity function. Maybe show us the code? – 66Gramms Jan 11 '21 at 10:31
-
transform.RotateAround(Vector3.zero, -Vector3.right, variableJoystick.Vertical * 200 * Time.deltaTime); – Aqib Ahmed Jan 11 '21 at 10:33
-
I wrongly mention Lookaround(), it is RotateAround() – Aqib Ahmed Jan 11 '21 at 10:34
-
Same code using for Horizontal movement – Aqib Ahmed Jan 11 '21 at 10:36
-
'transform.rotation = Quaternion.LookRotation(-Camera.main.transform.forward); // This one for cam rotation' and this code used for 2d text to focus and look towards camera – Aqib Ahmed Jan 11 '21 at 10:36
-
Please include a [minimal reproducible example](https://stackoverflow.com/help/minimal-reproducible-example) of your code in the question! – derHugo Jan 11 '21 at 11:32
1 Answers
1
Use Transform.LookAt. Get a reference to the camera's transform, for example with Transform mainCam = Camera.main.transform
then in the update function of your 2D text or any object you want to look at the camera use transform.LookAt(mainCam);

66Gramms
- 769
- 7
- 23
-
this.transform.LookAt(target.transform); >> also tried this. Same it rotates the 2d element clockwise and give not exact result – Aqib Ahmed Jan 11 '21 at 10:41