Playmaker Forum
PlayMaker Updates & Downloads => Share New Actions => Topic started 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
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();
}
}
}
-
This way better than the normal play animation at least it changes the animation back and forwards.
Thanks this is a huge help !!!