Raycasting now working on enemy AI

Hi guys
So, I’ve made a basic little shooting script, and a basic receiver, and it works just fine. However, when I add it to my AI object (Using A* Pathfinding and the AIPath script), it wont work at all.
Heres my shoot script-

`#pragma strict
var AllowFire : boolean = true;

function Start () {

}

function Update () {
if (Input.GetButton(“Fire1”)){
if (AllowFire == true){
Shoot();
}
}
}

function Shoot(){
AllowFire = false;
var rayhit : RaycastHit;
//var PlayRanger = transform.TransformDirection(Vector3(0,0,10));
var PlayRanger = transform.forward;
if (Physics.Raycast((transform.position + Vector3.up * 0.75),PlayRanger, rayhit)){
rayhit.transform.SendMessage (“HitByGun”);
Debug.DrawRay (transform.position, PlayRanger, Color.green);
}
yield WaitForSeconds (0.2);
AllowFire = true;
}`

`#pragma strict

function Start () {

}

function Update () {

}

function HitByGun(){
Debug.Log (“Hit”);
Destroy (gameObject);

}`

I have no idea what Im doing wrong here, since it works with non AI objects

Wel… I have no idea.
Your script is completely unrelated to any pathfinding things.
Check for colliders on the objects, they might be messing something up.

Its not unrelated to pathfinding, I copied my AI and removed all pathfinding components, and its works, so it must have something to do with pathfinding

Then it’s either the movement that is for some reason causing your script to fail, or the possible collider/character controller usually attached to AIs.

Try to debug it more and see what exactly is failing. Is it the raycast, is it the sendmessage call, etc.