2D Toolkit Forum

2D Toolkit => Support => Topic started by: Kenzo on April 06, 2014, 09:59:37 am

Title: Loadlevel after animation completed
Post by: Kenzo on April 06, 2014, 09:59:37 am
Hi just need to know can i load level after an animation finishes ?

Thanks guys ! u have great support !
Title: Re: Loadlevel after animation completed
Post by: unikronsoftware on April 06, 2014, 12:30:35 pm
Hi,
You'll need to write a script / use playmaker to do this. You can use the animationCompleteDelegate to find out when the animation has completed playing.
Title: Re: Loadlevel after animation completed
Post by: Kenzo on April 06, 2014, 12:37:47 pm
Code: [Select]
using UnityEngine;
using System.Collections;

public class Enemy : MonoBehaviour
{

    tk2dSpriteAnimator anim;
    GameObject currObject;


    // Use this for initialization
    void Start()
    {

    }
   
   // Update is called once per frame
    void Update()
    {
       currObject = GameObject.Find("Enemy_1");
                anim = currObject.GetComponent<tk2dSpriteAnimator>();

     if (!anim.IsPlaying("Enemy_Walk"))
                    anim.Play("Enemy_Walk");

anim.AnimationCompleted(........

    }




please help me complete that example C# code thanks :)
Title: Re: Loadlevel after animation completed
Post by: Kenzo on April 06, 2014, 06:13:11 pm
guys any help  ?  ::)
Title: Re: Loadlevel after animation completed
Post by: Kenzo on April 10, 2014, 06:59:52 pm
 :-[ :-[ :-[ :-[ :-[ :-[ :-[ :-[
Title: Re: Loadlevel after animation completed
Post by: unikronsoftware on April 11, 2014, 02:30:02 pm
Well if you're checking for anim.IsPlaying every frame, you can just wait until it stops playing (!IsPlaying) and then call LoadLevel then?
Title: Re: Loadlevel after animation completed
Post by: Kenzo on April 15, 2014, 05:53:43 pm
Well it's not working with that way since it is "still" playing cant even get that phase..

Can't you give me an example of Animation Completed event ? so i can figure it out
Title: Re: Loadlevel after animation completed
Post by: unikronsoftware on April 16, 2014, 10:18:20 am
tk2dDemoAnimationController.cs has an example of using the animation complete delegate. If your animation doesn't complete since it is "still playing", it isn't going to call the delegate? Polling IsPlaying should be no different to the delegate, if this doesn't work I wouldn't expect the animation complete delegate to fire either.