2D Toolkit Forum
2D Toolkit => Support => Topic started 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 !
-
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.
-
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 :)
-
guys any help ? ::)
-
:-[ :-[ :-[ :-[ :-[ :-[ :-[ :-[
-
Well if you're checking for anim.IsPlaying every frame, you can just wait until it stops playing (!IsPlaying) and then call LoadLevel then?
-
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
-
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.