- Home /
Question by
CubePhysics · Jul 14, 2013 at 10:37 AM ·
transformvector3variable
How do I change the position of a variable
I have a problem with my script. I always get an error. Can someone help me fix this script
#pragma strict
var camera = Transform;
function Update ()
{
if(Input.GetKeyDown(KeyCode.D))
{
camera.transform.position = Vector3(0.6871337, 0.5468787, -0.9462561);
}
}
Sorry im a newby at coding!
Comment
exactly what is the problem? is it not moving it? or what? also, have you assigned the camera transform to a transform in the inspector?
pointing the obvious;
did you assign the camera in the inspector?
sfc
Answer by BiG · Jul 14, 2013 at 12:57 PM
var camera = Transform;
is nonsense, because you are assigning a type to a variable. The correct synthax is:
var camera : Transform;
But, reading at your script, in line 10, I think you should do:
var camera : GameObject;
, since you are accessing its transform in that line of code.
And see also sfc.itzhak's comment, you'll have to assign the camera in the object's Inspector, later.