Hello Guest

Author Topic: Loadlevel after animation completed  (Read 5527 times)

Kenzo

  • Newbie
  • *
  • Posts: 10
    • View Profile
Loadlevel after animation completed
« 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 !

unikronsoftware

  • Administrator
  • Hero Member
  • *****
  • Posts: 9709
    • View Profile
Re: Loadlevel after animation completed
« Reply #1 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.

Kenzo

  • Newbie
  • *
  • Posts: 10
    • View Profile
Re: Loadlevel after animation completed
« Reply #2 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 :)
« Last Edit: April 06, 2014, 12:39:42 pm by Kenzo »

Kenzo

  • Newbie
  • *
  • Posts: 10
    • View Profile
Re: Loadlevel after animation completed
« Reply #3 on: April 06, 2014, 06:13:11 pm »
guys any help  ?  ::)

Kenzo

  • Newbie
  • *
  • Posts: 10
    • View Profile
Re: Loadlevel after animation completed
« Reply #4 on: April 10, 2014, 06:59:52 pm »
 :-[ :-[ :-[ :-[ :-[ :-[ :-[ :-[

unikronsoftware

  • Administrator
  • Hero Member
  • *****
  • Posts: 9709
    • View Profile
Re: Loadlevel after animation completed
« Reply #5 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?

Kenzo

  • Newbie
  • *
  • Posts: 10
    • View Profile
Re: Loadlevel after animation completed
« Reply #6 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

unikronsoftware

  • Administrator
  • Hero Member
  • *****
  • Posts: 9709
    • View Profile
Re: Loadlevel after animation completed
« Reply #7 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.