Hello Guest

Author Topic: SpriteAnimation Help - Parameters? Blend Tree? [Idle > Walk > Run > Sprint]  (Read 4639 times)

madclouds

  • 2D Toolkit
  • Newbie
  • *
  • Posts: 17
    • View Profile
Hello Forum!

I'm excited to be working on my first game with 2D Toolkit!  I could use some help understanding the SpriteAnimation feature and how it does, or does not play with the Unity Animator component?

In my game as you tap the screen, a 2d character runs.  The more you tap, the faster the run.  So the sequence would look like this:  Idle > Walk > Run > Sprint > Usain Bolt Speed - (Based on tapping speed).

I would love some help understanding how to tightly control the animations to give life to the character.  With a Unity Animation Controller, I would use a Speed parameter (float) and have Transitions based on the Speed value (0=idle, 0.1-0.3=walk, 0.3-0.9=run, etc).  I'd probably use a blend tree as well to perfectly match movement and animation.

Do you have any suggestions on the best way to animate my character smoothly through each movement speed using 2d Toolkit?

Thanks!

madclouds

  • 2D Toolkit
  • Newbie
  • *
  • Posts: 17
    • View Profile
I found a few related posts: 

http://2dtoolkit.com/forum/index.php/topic,3719.msg20372.html
http://2dtoolkit.com/forum/index.php/topic,3895.msg18589.html

Summary:  "[Unity Animator] can't animate c# properties. All tk2d properties are c# properties, and can't be animated in this way"

Any suggestions for handling a speed based animation would be greatly appreciated.   I'm worried about using animator.Play("Walk")/animator.Play("Run")/animator.Play("Sprint") will cause jumps or skips in the animation loops. 

Any thoughts?

unikronsoftware

  • Administrator
  • Hero Member
  • *****
  • Posts: 9709
    • View Profile
Assuming the clips have the same number of frames, you can use animator.PlayFromFrame("Sprint", animator.CurrentFrame);

madclouds

  • 2D Toolkit
  • Newbie
  • *
  • Posts: 17
    • View Profile
Thanks for the feedback.  I'll definitely give that a try.

As a follow up - is there any reason I shouldn't use Unity's Animation Controller & Clips to move/rotate the 2dtk sprites?  Seems like I could better control of animations vs png sequences.

BTW - great product and thanks for providing your input and knowledge.  It's as valuable as the software itself :D

Cheers

unikronsoftware

  • Administrator
  • Hero Member
  • *****
  • Posts: 9709
    • View Profile
You can move things around using animation controllers, there isn't any issue with that. THe only issue is that the animation system can't update properties on tk2d sprites - color being the main one.