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 :slight_smile:

Thanks in advance!!

I think it should be Camera.main.transform.position. Position is a member of the Transform class not the Camera class.

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