Cannot convert 'UnityEngine.Vector3' to 'float'.

I tried to google this before asking but the response I got back I did not understand? I was watching this youTube video for camera movements, http://www.youtube.com/watch?v=RkglrB6CBrE and I got the error mentioned in the tile. I do have programming experience in C, pascal (from school) and objective c.

#pragma strict

var moveSpeed:float = 3.0;

function Start () {

}

function Update () {
	if(Input.GetButtonDown("Forward")){
		transform.position.z = transform.forward * moveSpeed * Time.deltaTime;
	}
	
	if(Input.GetButtonDown("Backward")){
		transform.position.z = -transform.forward * moveSpeed * Time.deltaTime;
	}
}

So the return is a “vector3” that is trying to be assigned to my float?

you cant put a vector3 into a float. Get rid of the .z and make it transform.position = transform.forward * moveSpeed * Time.deltaTime;

I see. But if I remove the .z transitional for my position information where is that new value for z being defined so it knows that it is the z axis that I want movement in?

I’m not quite sure if I understand your problem.
But there is a Vector3 on both sides of the ‘=’.
(x, y, z) = (newX, newY, newZ)
In Unity SomeVector3.forward is the direction of the (positive) z-axis (0, 0, 1) (in local space). So when you multiply a scalar (moveSpeed * Time.deltaTime) only z changes.

Use either

// object moves along its local z-axis
transform.position += transform.forward * moveSpeed * Time.deltaTime; // or -= for moving backwards, instead of +=

or

// object moves along world's z-axis
var position = transform.position;
position.z += moveSpeed * Time.deltaTime;
transform.position = position;
// the same as above
transform.position += Vector3.forward * moveSpeed * Time.deltaTime;

Thanks guys. I was reading doc’s last night and running through video tutorials. There are somethings I find odd that I need to get use to programming wise. But it is nice that I can ask questions to this forum and have a response shortly after.

Thanks!