void doRay()
{
RaycastHit hit;
Ray ray;
if (cameraMode) {
ray = Camera.main.ScreenPointToRay(Input.mousePosition);
} else {
ray = new Ray(transform.position, transform.forward);
}
if (Physics.Raycast(ray, out hit)) {
isLooking = true;
isLookingAt = hit.collider.name;
Debug.Log(gameObject.name + " is looking at " + isLookingAt + ".");
if (target) {
if(isLookingAt==target.name) {
targetHit = true;
Debug.Log(gameObject.name + " has found target " + target.name + "!");
} else {
targetHit = false;
}
}
} else {
isLooking = false;
isLookingAt = "";
}
}