Position plane in front of camera

I have a map object that I wish to move in front of the camera and have it fill the camera's view. I do not want to move the camera, just move the object to be in front of the camera. Cannot figure it out.

4 Answers

4

You can get a point in front of the camera with

camera.transform.position + camera.transform.forward;

You can make the "map" face the camera with

map.transform.LookAt(camera.transform.position);

not sure why this got voted down but it seems the right answer?

http://unity3d.com/support/documentation/ScriptReference/Transform-position.html

that was unnecessarily vague and even mean of you.

these answers are both very relevant. Just another option you can consider is making the map appear as a GUI, just incase your camera moves about (though you can always parent your map to your camera) It's another thing to try atleast.

Using the GUI is a great idea except that the map has animations that play when opening and closing and colliders - neat map unfolding and folding.

In the end the solution was use the camera, where this is the map object itself:

this.gameObject.transform.position = theCamera.transform.position; this.gameObject.transform.rotation = theCamera.transform.rotation; this.gameObject.transform.Translate(0.0f, 0.0f, 7.0f); // move away from the camera this.gameObject.transform.LookAt(theCamera.transform.position);

Thank-you for the suggestions, they were helpful. Doing camera.transform.position + camera.transform.forward; worked in most scenes but placed the map in the middle of some objects in one scene.