Hello everyone!
I have a script in which I need to reference a prefab GameObject called BallFloating. This prefab GameObject (BallFloating) doesn’t instantiate until 10 seconds after run time begins. At 10 seconds it instantiates in the scene as BallFloating(Clone). Based on what I know so far (which is not much), the Find method is typically placed in Start which executes once at the beginning of run time. How can I Find and reference BallFloating or BallFloating(Clone) if it hasn’t been instantiated yet?
Here is my script:
using UnityEngine;
using System.Collections;
public class SetRightVelocityBall : MonoBehaviour
{
private BoolKeeper _refBoolKeeper;
private GameObject _refBall;
void Start ()
{
_refBoolKeeper = GameObject.Find("BoolKeeper").GetComponent<BoolKeeper>();
_refBall = GameObject.Find ("BallFloating(Clone)");
}
void Update ()
{
if (_refBoolKeeper.rightRacketCollision == true)
{
Debug.Log ("GOT IT!");
//do something to _refBall
}
}
}