- Home /
Placing a Gameobject in the exact Center of the Camera? (Closed)
Hey guys, I was wondering if anyone could help me find a way? The object just has to be in the exact center of the camera and remain there, with the same rotation of course (its already parented, but I find it really hard to place it exact).
Thank you in advance!
Answer by Julien-Lynge · May 31, 2013 at 08:46 PM
The question I have to ask is: The exact center of the camera at what distance?
Read up on the camera class to do this from script:
http://docs.unity3d.com/Documentation/ScriptReference/Camera.ScreenToWorldPoint.html
Or just take the child object, set the x and y position to zero, and move it along the z (forward) vector.
Sorry for asking this question way too quickly, because I already solved it :/ This is the Answer (maybe people looking for this sorta thing might need it) and you were right, Camera.ScreenToWorldPoint was what I used:
var FirePoint : GameObject;
function Start ()
{
FirePoint.transform.position = Camera.main.ScreenToWorldPoint( Vector3(Screen.width/2, Screen.height/2, Camera.main.nearClipPlane) );
}
Your answer
![](https://koobas.hobune.stream/wayback/20220613103310im_/https://answers.unity.com/themes/thub/images/avi.jpg)
Follow this Question
Related Questions
Camera rotation the same as player rotation 1 Answer
Rotating a GameObject based on another GameObject's y-axis 1 Answer
Rotating gameobject after mouselook 0 Answers
How to rotate a gameobject (Y Axis) via c#? 2 Answers
Rotate an Object 1 Answer