Playmaker Forum
PlayMaker Help & Tips => PlayMaker Help => Topic started by: msc4tech on December 02, 2011, 06:51:54 AM
-
I need to manage the trigger that sends animations including 2dtoolkit. How can you create an action that allows you to do this?
Thanks
-
no solution for this problem
-
Hi,
Definitly a solution :)
Give me another day, and I'll provide you with something.
I have looked at the help, tho I don't own 2d toolkit, you will likely need to fiddle with my example as I can't test. If you are ready to invest the few bucks for me to get a license, then I'd happily provide even more than just a trigger from the animation system ( I did so too with Sprite manager 2).
Bye,
Jean
-
Ok,
I have something. TOTALLY UNTESTED, written based on the documentation available on 2dToolkit
http://www.unikronsoftware.com/2dtoolkit/wiki/pmwiki.php/Main/ScriptingAnAnimatedSprite (http://www.unikronsoftware.com/2dtoolkit/wiki/pmwiki.php/Main/ScriptingAnAnimatedSprite)
Given that script sample, I think the following will work:
using UnityEngine;
using HutongGames.PlayMaker;
[ActionCategory("2d toolkit")]
[Tooltip("2D toolkit Animation Complete Trigger")]
public class Toolkit2dAnimationEvent : FsmStateAction {
[CheckForComponent(typeof(tk2dAnimatedSprite))]
public FsmOwnerDefault gameObject;
public FsmEvent AnimationCompleteEvent;
private GameObject go;
private tk2dAnimatedSprite _component;
public override void Reset() {
gameObject = null;
AnimationCompleteEvent = null;
}
public override void OnEnter() {
go = gameObject.OwnerOption == OwnerDefaultOption.UseOwner ? Owner : gameObject.GameObject.Value;
_component = go.GetComponentInChildren<tk2dAnimatedSprite>();
_component.animationCompleteDelegate = AnimationComplete_DELEGATE;
Finish();
}
void AnimationComplete_DELEGATE(tk2dAnimatedSprite sprite, int clipId){
Fsm.Event(AnimationCompleteEvent);
}
}
If someone has 2d toolkit, I would greatly appreciate a test with this custom action just to validate it. If you get errors or if it's not working, do not hesitate to get back to me :)
Bye,
Jean
-
thanks for the script.
I have make more 2d toolkit action into share action section.
thanks
Vins
-
Hi Vins,
Way to go !!
One thing:
if you design your actions using
[CheckForComponent(typeof(tk2dAnimatedSprite))]
public FsmOwnerDefault gameObject;
This will ensure that you can't select a gameObject not featuring tk2d, else you would get script errors.
Are you ok if I feature your scripts onto the wiki, cause I think it will get more exposure like so, I am sure people will find this very useful. You would of course get credited for it, etc etc.
Bye,
Jean
-
Thanks jean