Playmaker Forum

PlayMaker Updates & Downloads => Share New Actions => Topic started by: rocket5 on August 28, 2011, 08:43:21 PM

Title: 2D Toolkit Play() Animation
Post by: rocket5 on August 28, 2011, 08:43:21 PM
Here's an Action that will play an animation on a 2D Toolkit Animated Sprite (tk2dAnimatedSprite).  This is my first Action so I don't know yet if there's a better way to do this, but it works!  -Tim

Code: [Select]
using UnityEngine;

namespace HutongGames.PlayMaker.Actions
{
[ActionCategory("2D Toolkit")]
[Tooltip("Plays a sprite animation on a tk2dAnimatedSprite")]
public class PlayAnim : FsmStateAction {
[RequiredField]
public FsmOwnerDefault gameObject;
public FsmString clipName;

private GameObject go;
private tk2dAnimatedSprite spriteAnim;

public override void Reset() {
gameObject = null;
clipName = null;
}

public override void OnEnter() {
go = gameObject.OwnerOption == OwnerDefaultOption.UseOwner ? Owner : gameObject.GameObject.Value;
spriteAnim = go.GetComponent<tk2dAnimatedSprite>();
spriteAnim.Play(clipName.Value);
Finish();
}
}
}
Title: Re: 2D Toolkit Play() Animation
Post by: midnight_stories on December 15, 2012, 08:53:34 AM
This way better than the normal play animation at least it changes the animation back and forwards.
Thanks this is a huge help !!!