My Vector3 changes all values to 0

Hi guys.
Im just playing around in Unity and noticed my code for my Vector3 doesnt work and it doesnt make sense or im just stupid ?

var vectorPosition : Vector3 = Vector3(10, 50, 10);

function Update () {
	if(Input.GetButtonDown("Jump")) {
	transform.position = vectorPosition;
	}
}

Every time a press space it just transforms it to 0, 0, 0.
Help please?
Thanks

It’s generally not a good idea to initialize variables values during variable declaration. This is because public variables show up in the inspector, so any value there overrides the initialized value and can cause issues and confusion.

If you look in the inspector I expect you’ll see the vectorPosition value is <0,0,0>. Try changing the value in the inspector to <10,50,10> and I suspect it will work.

It’s usually better to initialize the value in the Awake or Start functions.

var vectorPosition : Vector3;

function Start()
{
  vectorPosition = Vector3(10, 50, 10);
}