// Update is called once per frame void Update() { if(ballHandler == null) ballHandler = FindObjectOfType(typeof(SpitBallHandler)) as SpitBallHandler; lifeTimer += Time.deltaTime; if(lifeTimer >= timeToLive) { lifeTimer = 0; ballHandler.PushSpitBall(gameObject); } }
void Start() { ballHandler = FindObjectOfType(typeof(SpitBallHandler)) as SpitBallHandler; }