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