Hi there everyone! So, I’m currently making a weapon for my game, and when I shoot it and it hits the target, it should disable his patroling script, but it totally doesn’t.Any other thing works fine, like let’s say the animations or the navmeshagent work as intended and get changed/disabledd.
I have tried different techniques like the following :
// tried this
GetComponent<FOVDetection>().enabled = false;
// tried getting the game object before accesing this
public GameObject killer;
Killer.GetComponent<FOVDetection>().enabled = false;
// also tried declaring a monobehaviour and disable that
public MonoBehaviour script;
void Start() {
script = GetComponent<FOVDetection>();
}
// and then trying to do this
script.enabled = false;
// Tried searching the gameObject and disable it like that
GameObject.Find("Killer").GetComponent<FOVDetection>().enabled = false;
// Also tried like this
FOVDetection fovdetection = GetComponent<FOVDetection>();
// and then disabling it like this
fovdetection.enabled = false;
Let’s just say I tried a bunch of ways.I also tried deleting the awake method in the FOVDetection script and keeping all of that together with the other stuff that was in start, that also didn’t work.I’ve ran out of ideas and I needed to finish this so I could push my app update before the deadline that I’ve set for myself.
Does anybody have any sort of idea why this is happening and how I could fix it?I’m desperate at this point as I can’t understand what is going wrong in here.
Thank you so much for the help!