Hi guys, I’m new here and I am hoping that I can find some help…
this line:
// Vector3 curPos = this.transform.FindChild (“Plane”).position;
is throwing a warning in unity saying that the:
‘UnityEngine.Transform.FindChild’ is obsolete; ‘FindChild has been depreceated. Use Find instead (UnityUpgradable)-> Find([mscorlib] System.String)’.
I’m following a vid on PluralSight for creating a light switch puzzle game. However, it seems Unity no longer uses FindChild, but I don’t know how to use the alternative that Unity has suggested. I have added the code the vid used and continued on with. None of the previous comments on the course mention having this error, though the last comment made was a year ago and Unity has updated since.
the 3 instances of FindChild in the code each call up the previously mentioned warning.
public void change(){ // Lights will change position as they change between on and off. Updated plane from cube.
Vector3 curPos = this.transform.FindChild ("Plane").position;
if(isOn){
isOn = false; // lights off.
this.transform.FindChild ("Plane").position = new Vector3(curPos.x,curPos.y,curPos.z +.5f);
}else{
isOn =true; // Lights on
this.transform.FindChild ("Plane").position = new Vector3(curPos.x,curPos.y,curPos.z -.5f);
}
}