The question is answered
Cant use 'var' to define Vector3?
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);
}
Answer by NoseKills · Jul 01, 2016 at 06:34 AM
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
}
Answer by JigneshKoradiya · Jun 30, 2016 at 06:42 AM
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);
}
UnityEngine.Vector3' does not contain a definition for
Zero'
Is there something else besides the using UnityEngine and using System.Collections I should have when trying to use touch screen?
Follow this Question
Related Questions
Efficiency between getcomponent<> and save reference in a variable 0 Answers
Efficiency when declaring variables 3 Answers
Is it possible to define a variable of multiple types? 2 Answers
String variable declared in editor goes blank at runtime 0 Answers
change the variable of enemy to attack 0 Answers