How do I use LeanTween "onComplete"?

private void displayGo()
{	
	Hashtable gameStartScalePara = new Hashtable();
	gameStartScalePara.Add("ease", LeanTweenType.easeOutBounce);
	gameStartScalePara.Add ("onComplete", "displayGo");

	LeanTween.scale(_gameStartObject, Vector3.one, 1, gameStartScalePara);
}

I got this error, BroadcastMessage displayGo has no receiver!. Why is these so? Anyone?

Thanks…!

Hi Tongie,
When you pass in the “onComplete” as a String it is assuming that the function that needs to be called is on the GameObject you are animating. If the target is different than that you need to pass another parameter “onCompleteTarget”, such as:

gameStartScalePara.Add ("onCompleteTarget", gameObject);

Here an example works fine:

if (LeanTween.isTweening(placarFundoRect) == false  placarFundoInteragir == true)
        {
            Vector2 orig = new Vector2(0.5f * Screen.width - placarFundo.width * 0.5f, 0.5f * Screen.height - placarFundo.height * 0.5f);
            htb = new Hashtable(); htb.Add("ease", LeanTweenType.easeOutBounce); htb.Add("onCompleteTarget", this.gameObject); htb.Add("onComplete", "somPlacar");
            LeanTween.move(placarFundoRect, new Vector2(1.0f * Screen.width + placarFundo.width, placarFundoRect.rect.y), 2f, htb);
            htb = new Hashtable(); htb.Add("ease", LeanTweenType.easeOutBounce); htb.Add("delay", 1.0f);
            LeanTween.move(placarFundoRect, orig, 1.0f, htb);
        }

The code called:

  void somPlacar()
    {
        tocarSom(placarFundoBateu);
        placarAboboraInteragir = true;
    }

to avoid starting the leantween animation if it is not finished yet, you might use onComplete with an integrated lamda action like this:

private LTDescr _leanTweenPlayerEnemyContact;

        if (_leanTweenPlayerEnemyContact == null)
            _leanTweenPlayerEnemyContact = LeanTween.alpha(gameObject, 0.25f, 0.5f).setLoopPingPong(1).setOnComplete( ()=> { _leanTweenPlayerEnemyContact = null; } );
2 Likes