Camera get position vector3 (solved)

Edit: Think i got it solved, or at least iam a step further :). The following thread is a great ressource
WOW Camera Movement

The new flawlessly working script you can find in the 3rd post

Here the old Post:
Ok, first post so hello everyone. Excuse me for my newbish question, but i tried that thing for hours now and i cant get it to work… What i actually want is the following:

1.Get player camera position at start of this camera control script
2.Store the value in a custom vector3
3. use the y.value of the custom.vector3 to determine default zoom distance
4. Set a min/max value for min/max zoom distance

for 1 2.
So first i wanted to declare a variable vector3 outside of the functions in which the cameras start position is going to be stored. then i wanted to equal that vector 3 with the ones that i can get from Camera.current.transform.position
in the Start function.

the rest i wanna figure myself, but i cant get 1 2 to work without knowing how to. I appreciate any help or pointers in the right direction. My first custom script… took me a whole day and i actually dont want to spend more time on it, so help me finish it tonight :wink:

And here the complete script i made so far. I know you will see the problem with the vector3 and the Camera.current.transform.position but i have actually no idea how to put it right. Tried a lot of combinations now… Anyway, pls have a look. Works like a charm except that vector3 stuff

var arrowkeyspeed = 1.0;
var mousescrollbuttonspeed = 1.0;
var mouse3rdbuttonzoomspeed = 1.0;
var panspeed = 1.0;
var maxzoomin = 1.0;
var maxzoomout = 1.0;
var defaultcameraposition.Vector3 : Vector3;

function Start () {

defaultcameraposition = Camera.current.transform.position;
	}
function Update () {

	// use the left/right key to move camera to left or right direction
	var moveleftrightkeys = Input.GetAxis ("Horizontal") * arrowkeyspeed;
	moveleftrightkeys *= Time.deltaTime;
	transform.Translate (moveleftrightkeys, 0, 0 ); 
	
	//use the up/down key to move camera to up or down direction
	var moveupdownkeys = Input.GetAxis ("Vertical") * arrowkeyspeed ;
	moveupdownkeys *= Time.deltaTime;
	transform.Translate (0, moveupdownkeys , 0);
		
	//zoom in/out turning the mouse wheel	
	var zoominoutmousescroll = Input.GetAxis ("Mouse ScrollWheel") * mousescrollbuttonspeed;
	zoominoutmousescroll *= Time.deltaTime;
	transform.Translate (0, 0 , zoominoutmousescroll);
	//zoom in/out holding 3rd mousebutton and moving mouse up or down 

	if (Input.GetButton ("Fire3")) {
		var zoominoutmouse3rdbutton = Input.GetAxis("Mouse Y") * mouse3rdbuttonzoomspeed;
		zoominoutmouse3rdbutton *= Time.deltaTime;
		transform.Translate (0, 0 , zoominoutmouse3rdbutton);
	}

	// pan direction holding right mouse button and dragging into desired direction
	if (Input.GetButton("Fire2")) {
		var panmouse2ndbuttonx = Input.GetAxis("Mouse X") * panspeed;
		panmouse2ndbuttonx *= -Time.deltaTime;
		var panmouse2ndbuttony = Input.GetAxis("Mouse Y") * panspeed;
		panmouse2ndbuttony *= -Time.deltaTime;
		transform.Translate ( panmouse2ndbuttonx , 0 , 0 );
		transform.Translate ( 0 , panmouse2ndbuttony , 0);
	}
	
}

@script RequireComponent(CharacterController)

You declare a Vector3 variable in JS like this:

var defaultcameraposition : Vector3;

And the best thing to do would be to make the script attached to your main camera, so you would use it like this:

function Start () {

defaultcameraposition = transform.position;
   }

thx for your comment Vimalakirti. I see you help alot of ppl here so i really appreciate your tips and hints. I figured it out yesterday night, or actually this morning :roll:. At least i finished it in one day. But i changed some things to the script according to your tips, especially for the line:
before:
defaultcameraposition = Camera.current.transform.position
after:
defaultcameraposition = transform.position.y ;

also no more vector3 variable declaration, since i only need the [1] from the camera position. Again, thx for the help and here the script with the following functions:

Zoom in/out = Scrollwheel
Pan = 3rd MouseButton
move Cam = Arrowkeys

Values for all can be set and also a max value for zoom in and out. I think this is a ok script for a sidescroller or a small top down RTS (for which iam actually making this).

var arrowkeyspeed = 1.0;
var mousescrollbuttonspeed = 1.0;
var panspeed = 1.0;
var maxzoomin = 1.0;
var maxzoomout = 1.0;
private var cameraposition = 0;
private var defaultcameraposition = 0;
private var maxcameraposition = 0;
private var mincameraposition = 0;

function Start () {
	//getting the camera position on script startup and store its y value in a custom variable for use later on
	defaultcameraposition = transform.position.y ;

	//setting the max and min y cameraposition	
	maxcameraposition = defaultcameraposition + maxzoomout;
	mincameraposition = defaultcameraposition - maxzoomin;
}

function Update () {

	// use the left/right key to move camera to left or right direction
	var moveleftrightkeys = Input.GetAxis ("Horizontal") * arrowkeyspeed;
	moveleftrightkeys *= Time.deltaTime;
	transform.Translate (moveleftrightkeys, 0, 0 ); 
	
	//use the up/down key to move camera to up or down direction
	var moveupdownkeys = Input.GetAxis ("Vertical") * arrowkeyspeed ;
	moveupdownkeys *= Time.deltaTime;
	transform.Translate (0, moveupdownkeys , 0);

	//zoom in/out turning the mouse wheel	
	var zoominoutmousescroll = Input.GetAxis ("Mouse ScrollWheel") * mousescrollbuttonspeed;
	zoominoutmousescroll *= Time.deltaTime;
	transform.Translate (0, 0 , zoominoutmousescroll);
	
		cameraposition = transform.position.y ;		
		if ( cameraposition > maxcameraposition) {
			transform.position = Vector3( transform.position.x , maxcameraposition , transform.position.z);
		}
		if ( cameraposition < mincameraposition) {
			transform.position = Vector3( transform.position.x , mincameraposition , transform.position.z);
		}			
	
	// pan direction holding right mouse button and dragging into desired direction
	if (Input.GetButton("Fire3")) {
		var panmouse2ndbuttonx = Input.GetAxis("Mouse X") * panspeed;
		panmouse2ndbuttonx *= -Time.deltaTime;
		var panmouse2ndbuttony = Input.GetAxis("Mouse Y") * panspeed;
		panmouse2ndbuttony *= -Time.deltaTime;
		transform.Translate ( panmouse2ndbuttonx , 0 , 0 );
		transform.Translate ( 0 , panmouse2ndbuttony , 0);
	}	
}

@script RequireComponent(CharacterController)