Identical Lines of Code Will Either Disable, or Wont Disable a Script. Need Help.
I have the following two scripts. One will disable the script, while the other one wont. The print statements will print for both, meaning the function is being executed, but only one of them (the armbreak script) will disable the script. There are no errors printed in the console. All the scripts are in the same folder and are all in C#. Anyone have any idea what could be happening?
Heres the script that works:
using UnityEngine;
using System.Collections;
public class armbreak : MonoBehaviour {
public GameObject Enemy;
void OnJointBreak(float breakForce)
{
print (breakForce);
Enemy.GetComponent ().enabled = false;
}
}
Heres the script that doesn't work:
using UnityEngine;
using System.Collections;
public class HandPistolBReak : MonoBehaviour {
public GameObject Enemy;
void OnJointBreak(float breakForce)
{
Enemy.GetComponent ().enabled = false;
print ("broken with" + breakForce);
}
}
only the second uses print. besides that, they are identical, so they're either on different gameobject where one joint breaks and one doesn't, or on the same gameobject and by the looks of GetComponent() without a specified type(didn't even know that works), only the first script might be found in both cases.
What is Enemy.GetComponent ()
supposed to do? Aren't you getting compile errors?
Your answer
Follow this Question
Related Questions
Cant Disable Script on Another Gameobject 1 Answer
Animation 0 Answers
"The associated script cannot be loaded." 0 Answers
Unity keeps rejecting my code, even when there are no errors 1 Answer