Hello everyone !
I would like to know how to "center" an object relative to my camera (to see it in the middle of the screen) in JS (if it's possible). Any idea? :)
Hello everyone !
I would like to know how to "center" an object relative to my camera (to see it in the middle of the screen) in JS (if it's possible). Any idea? :)
You can use the Camera.ScreenToWorldPoint() method to get a point in the middle of the screen
For example:
targetGameObject.transform.position = Camera.main.ScreenToWorldPoint( Vector3(Screen.width/2, Screen.height/2, Camera.main.nearClipPlane) )