- Home /
Center an object to a camera
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? :)
Comment
Best Answer
Answer by JakeElliott · Jan 30, 2011 at 11:07 PM
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) )
Your answer
Follow this Question
Related Questions
Camera Orbiting Character: How to make an object move with another with no rotation 1 Answer
Make object follow mouse, while actually moving camera, instead of object 2 Answers
Attaching an object to a camera movement weird, Help! 2 Answers
Rotate Camera around Object 2 Answers
Camera rotate around sphere centre 2 Answers