- Home /
Question by
ThomasQ · Aug 04, 2011 at 10:52 AM ·
camerapositionbce0019camera.main
Camera.main.position gives BCE0019
Hi All!
I'm trying to get the main camera's position, but using
Camera.main.position
gives me a BCE0019: 'position' is not a member of 'UnityEngine.Camera' error..
I'm using it in this script
function LateUpdate()
{transform.position = Camera.main.position;}
How do I fix this? This code was recommended to me, I wouldn't know what's wrong with it :)
Thanks in advance!!
Comment
Best Answer
Answer by Blankzz · Aug 04, 2011 at 11:02 AM
I think it should be Camera.main.transform.position. Position is a member of the Transform class not the Camera class.
Answer by Graham-Dunnett · Aug 04, 2011 at 11:06 AM
Camera.main gives you a Camera. If you look at http://unity3d.com/support/documentation/ScriptReference/Camera.html you'll see that a Camera does not have a position. A Camera does have a transform, and a transform has a position, so you need:
Camera.main.transform.position
Your answer
![](https://koobas.hobune.stream/wayback/20220612170107im_/https://answers.unity.com/themes/thub/images/avi.jpg)