raycast hit wrong point . this script give to sniper weapon.
raycast does not hit object(add animation)
please help
code↓
#pragma strict
function Start () {
}
function Update () {
var cam : Transform = Camera.main.transform;
var ray = new Ray(cam.position, cam.forward);
var hit : RaycastHit;
if(Physics.Raycast (ray, hit, 500)) {
if (Input.GetMouseButtonDown(0) && hit.collider.gameObject.tag == "Enemy") {
print ("enemy!");
Destroy(hit.collider.gameObject);
}
}
}