How can I make this only run once, because it seems like it searches for the object after it removed it, I’ll show you what I mean.
In script of main object:
FixedUpdate(){
if(Match){
bool doOnce = true;
if(doOnce){
doOnce = false;
Hex hex;
hex = transform.Find("Hex").gameObject.transform.GetComponent<Hex>();
hex.DetachHex();
}
transform.localScale = Vector3.Lerp(transform.localScale, new Vector3(0.1f, 0.1f, 0.1f), 1*Time.deltaTime );
}
}
in hex:
public void DetachHex(){
transform.parent = null;
}
But when I run the code this happens:
NullReferenceException: Object reference not set to an instance of an object
MainScript.FixedUpdate ()