Alright so Im a bit stuck. What I am trying to do is access a script on the gameObject which is where I handle damaged (I prefer to keep a few things out from my AI script such as damage) and what I am trying to do it that when I shoot my enemy when I am out of his field of view he changes his state to attacking me.
Now this is simple enough you can just put an if statement wondering if that scripts static boolean values gettingHurt is true. This works fine but if I shoot an enemy with the damage receiving script since that scripts become true the AI script reads through all damage receiving scripts and since one gettingHurt is true it changes its state.
if (DamageReceiver.gettingHurt == true){
transform.LookAt(target);
if (ableToShoot == true)
{
InvokeRepeating("Shoot", 0.001f, gunROF);
ableToShoot = false;
}
}
(This is a seperate AI code for a MG nest which is not using a state machine but it still needs the same thing done to it. Figured I might show some script.)
Also I have tried using gameObject.GetComponent in various methods but I can not seem to get it to work right or I get the error (something forgot the first part as I have reverted script so it works so I could work and test other things )cannot be accessed with an instance reference, qualify it with a type name instead
Thank you for your help