playMaker

Author Topic: 2d toolkit animation [SOLVED]  (Read 5656 times)

msc4tech

  • Playmaker Newbie
  • *
  • Posts: 17
    • http://www.msc4tech.com
2d toolkit animation [SOLVED]
« 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
« Last Edit: December 10, 2011, 11:43:42 PM by alexchouls »

msc4tech

  • Playmaker Newbie
  • *
  • Posts: 17
    • http://www.msc4tech.com
Re: 2d toolkit animation
« Reply #1 on: December 05, 2011, 05:14:37 AM »
no solution for this problem

jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 15500
  • Official Playmaker Support
Re: 2d toolkit animation
« Reply #2 on: December 05, 2011, 07:48:07 AM »
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

jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 15500
  • Official Playmaker Support
Re: 2d toolkit animation
« Reply #3 on: December 06, 2011, 04:39:02 AM »
Ok,

 I have something. TOTALLY UNTESTED, written based on the documentation available on 2dToolkit

http://www.unikronsoftware.com/2dtoolkit/wiki/pmwiki.php/Main/ScriptingAnAnimatedSprite

Given that script sample, I think the following will work:

Code: [Select]
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

msc4tech

  • Playmaker Newbie
  • *
  • Posts: 17
    • http://www.msc4tech.com
Re: 2d toolkit animation
« Reply #4 on: December 06, 2011, 07:08:24 AM »
thanks for the script.
I have make more 2d toolkit action into share action section.
thanks

Vins

jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 15500
  • Official Playmaker Support
Re: 2d toolkit animation
« Reply #5 on: December 06, 2011, 07:40:02 AM »
Hi Vins,

 Way to go !!

One thing:

if you design your actions using

Code: [Select]
[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

msc4tech

  • Playmaker Newbie
  • *
  • Posts: 17
    • http://www.msc4tech.com
Re: 2d toolkit animation
« Reply #6 on: December 07, 2011, 03:58:32 AM »
Thanks jean