- Home /
Problem with var in C# (Vector3, transform and similiar)
Hello. Can someone help me with this error:
Assets/scriptPlayer.cs(22,47): error CS0119: Expression denotes a type', where a
variable', value' or
method group' was expected
And here is code : using UnityEngine; using System.Collections;
public class scriptPlayer : MonoBehaviour { public RaycastHit hit; public Ray ray; public Vector3 pos;
void Update () {
if (Input.GetMouseButtonDown(0))
{
Debug.Log("Yes the button works");
ray = Camera.main.ScreenPointToRay(Input.mousePosition);
if (Physics.Raycast(ray,out hit,100.0f))
{
if (hit.transform.tag == "enemy")
{
pos = Vector3(Random.Range(-6,6),Random.Range(-3,3),0);
hit.transform.position=pos;
Debug.Log("Ray hit");
}
}
}
}
}
Comment