There are 2 scripts involved. One is attached to the main parent (which is a aeroplane) the second is attached a couple of children levels lower on a gear object.
when the Current Altitude hits X the function on the second script is called to play the animation.
again, this works fine if only one prefab is in the scene. more than one then its not so fine.
Ive not used any static variables anywhere so that shouldbt be the issue.
Totally at a loss now, wasted the day - any help would be great.
sample of the code, which works fine if only one prefab exists in the scene.
private void Start()
{
anim = this.gameObject.GetComponent<Animator>();
TakeOffAlt = FindObjectOfType<AI_MQ9>().TakeOffAlt;
}
private void Update()
{
if (FindObjectOfType<AI_MQ9>().CurrentAlt > TakeOffAlt
&& geardone == false)
{
GearUp();
geardone = true;
}
}
public void GearUp()
{
if (geardone == false)
{
anim.Play("GearUp");
GearUpSound.Play();
Debug.Log("Gear Up " + name);
}
}