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!
BiG
2
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.