Getting an error for using var, tried a few things but nothing works or makes it worse. How do I define a Vector variable?
private var pos = new Vector3(0, 0, 0);
void Update()
{
pos = Camera.main.ScreenToWorldPoint (Vector3 (Input.GetTouch (0).position.x, Input.GetTouch (0).position.y, 5));
transform.position = new Vector3 (pos.x, pos.y, pos.z);
}
private Vector3 pos = Vector3.Zero;
void Update()
{
pos = Camera.main.ScreenToWorldPoint (Vector3 (Input.GetTouch (0).position.x, Input.GetTouch (0).position.y, 5));
transform.position = new Vector3 (pos.x, pos.y, pos.z);
}
Its a lower case z Vector3.zero
You can’t use the var keyword for fields or constants, only local variables
var vect = Vector3.zero; // not ok
public void Update() {
var vect1 = Vector3.zero; // ok
}