Hello Guest

Author Topic: Offset Specific Frame in Sprite Animation  (Read 11625 times)

regnared

  • 2D Toolkit
  • Newbie
  • *
  • Posts: 27
    • View Profile
    • Mah website
Offset Specific Frame in Sprite Animation
« on: November 28, 2012, 08:16:58 pm »
Is it possible to offset ( X and/or Y) specific frames in the animation sequence?

Currently this is what I see when I use my character frames :


I would like to be able to put a Y offset for walk_01 frame to give a more dynamic feel to the walking sequence. Like this :



Is there a way to do the offset in the Sprite Animation editor? Right now the only method I found was to add an empty (0.01% oppacity) pixel in the frame, but that is not ideal when creating dynamic animations.
« Last Edit: November 29, 2012, 08:01:04 pm by regnared »

unikronsoftware

  • Administrator
  • Hero Member
  • *****
  • Posts: 9709
    • View Profile
Re: Offset Specific Sprite in Sprite Animation
« Reply #1 on: November 28, 2012, 11:26:52 pm »
You can't at the moment. You could add this behaviour quite easily though. Let me know if you'd like to attempt this and I can explain in a bit more detail.

p.s. you don't need a 0.01 opacity pixel row, a 0 opacity one will do fine.

regnared

  • 2D Toolkit
  • Newbie
  • *
  • Posts: 27
    • View Profile
    • Mah website
Re: Offset Specific Sprite in Sprite Animation
« Reply #2 on: November 29, 2012, 08:00:16 pm »
Quote
You can't at the moment. You could add this behaviour quite easily though. Let me know if you'd like to attempt this and I can explain in a bit more detail.

So I could add this feature to the animation editor? Wow, that would be pretty cool. :) Even if it is basic tools to offset sprites, it can make the animation editor that much more awesome. Are you planning to add this feature in future patches of 2dtk ? It would make for a solid animation tool as well.

With that thought in mind, I made a mockup with suggestions that might bring the animation editor even cooler. These pop-ed into my mind as I worked more in depth with the editor on my game. (I've worked as a sprite editor in the industry in the past, most of these suggestions come from my experience with those engines I worked on.) Just to show what might be useful for animators out there and speed up the workflow process. (And if ever you plan to update it with more options that will benefit other devs.) I know it is a lot of work to implement, so not expecting nothing out of this. Just food for thought.  :)

(Sorry for the long post, I guess this could be posted in a "could be cool to have feature post".)





[ Quick Explanation ] :


The Flip Horizontal and Flip Vertical Main Button  - When you click it toggles ON/OFF the horizontal/vertical flip option for all frames
Mighty useful if you have a big Walkcycle. Make all the frame look at the left. Creating the right facing direction can be done simply with one click! Wow. This is quicker, and clean. You save space and it is really less tedious then manually flipping horizontally the frames, say in Photoshop. Great for being efficient.


Hide/Unhide toggle options for each frame - When the toggle is set to ON, the sprite will be hidden when the animation clip plays
The Hide/Unhide option is a really powerful tool to quickly see if your animation could be done in less frame and still feel right. Making it easy to see if the frame is valuable or not. When the hide toggle is on, the animation simply skips this frame like it's not part of the anim clip.


Delete frame - When you click the - button, the frames get deleted
After you hidden the frame, you realise that frame doesn't look good. You want it out. Instead of deleting all the other frames, then adding the autofill again, you simply delete this frame. Takes one second and it's done. Nice and quick.


Horizontal and Flip toggle options for each frame - When the toggle is set to ON, the sprite will flip horizontally and/or vertically
Basic but mighty useful when animation sprites. A lot can be done with this feature. Save space, you don't need to manually flip the frames in Photoshop, nor do you need to code anything.


Offset X/Y Area - Offset the Sprite in the X and/or Y value when the animation plays
Another basic nice animation tool. Instead of making the sprites bigger with empty space, you can simply offset the sprites directly in the editor. Quickly making it easy to tweak and see live if the animation looks good.
« Last Edit: November 29, 2012, 08:02:44 pm by regnared »

unikronsoftware

  • Administrator
  • Hero Member
  • *****
  • Posts: 9709
    • View Profile
Re: Offset Specific Sprite in Sprite Animation
« Reply #3 on: November 30, 2012, 10:03:16 am »
Hi there,

Thanks for the suggestions, and I really appreciate you taking the time to write out all of this. I'm totally rewriting the sprite animation editor. Brand new interface not limited to the shackles of inspector any more, so a lot of these will be quite (very) different then. Would you mind if I got some input from you when it gets a bit more stable?

Quote
You can't at the moment. You could add this behaviour quite easily though. Let me know if you'd like to attempt this and I can explain in a bit more detail.

So I could add this feature to the animation editor? Wow, that would be pretty cool. :) Even if it is basic tools to offset sprites, it can make the animation editor that much more awesome. Are you planning to add this feature in future patches of 2dtk ? It would make for a solid animation tool as well.

With that thought in mind, I made a mockup with suggestions that might bring the animation editor even cooler. These pop-ed into my mind as I worked more in depth with the editor on my game. (I've worked as a sprite editor in the industry in the past, most of these suggestions come from my experience with those engines I worked on.) Just to show what might be useful for animators out there and speed up the workflow process. (And if ever you plan to update it with more options that will benefit other devs.) I know it is a lot of work to implement, so not expecting nothing out of this. Just food for thought.  :)

(Sorry for the long post, I guess this could be posted in a "could be cool to have feature post".)





[ Quick Explanation ] :


The Flip Horizontal and Flip Vertical Main Button  - When you click it toggles ON/OFF the horizontal/vertical flip option for all frames
Mighty useful if you have a big Walkcycle. Make all the frame look at the left. Creating the right facing direction can be done simply with one click! Wow. This is quicker, and clean. You save space and it is really less tedious then manually flipping horizontally the frames, say in Photoshop. Great for being efficient.


Hide/Unhide toggle options for each frame - When the toggle is set to ON, the sprite will be hidden when the animation clip plays
The Hide/Unhide option is a really powerful tool to quickly see if your animation could be done in less frame and still feel right. Making it easy to see if the frame is valuable or not. When the hide toggle is on, the animation simply skips this frame like it's not part of the anim clip.


Delete frame - When you click the - button, the frames get deleted
After you hidden the frame, you realise that frame doesn't look good. You want it out. Instead of deleting all the other frames, then adding the autofill again, you simply delete this frame. Takes one second and it's done. Nice and quick.


Horizontal and Flip toggle options for each frame - When the toggle is set to ON, the sprite will flip horizontally and/or vertically
Basic but mighty useful when animation sprites. A lot can be done with this feature. Save space, you don't need to manually flip the frames in Photoshop, nor do you need to code anything.


Offset X/Y Area - Offset the Sprite in the X and/or Y value when the animation plays
Another basic nice animation tool. Instead of making the sprites bigger with empty space, you can simply offset the sprites directly in the editor. Quickly making it easy to tweak and see live if the animation looks good.

regnared

  • 2D Toolkit
  • Newbie
  • *
  • Posts: 27
    • View Profile
    • Mah website
Re: Offset Specific Frame in Sprite Animation
« Reply #4 on: November 30, 2012, 07:27:05 pm »
Quote
Hi there,

Thanks for the suggestions, and I really appreciate you taking the time to write out all of this. I'm totally rewriting the sprite animation editor. Brand new interface not limited to the shackles of inspector any more, so a lot of these will be quite (very) different then. Would you mind if I got some input from you when it gets a bit more stable?

Hello! After all the hard work you put into this plugin, I would be delighted in testing out the new revamped sprite animation editor. Quite excited to see what you have been up to with it. :) Here's my email if you want to shoot me a message once it's more stable : philippe@philippechabot.com 


unikronsoftware

  • Administrator
  • Hero Member
  • *****
  • Posts: 9709
    • View Profile
Re: Offset Specific Frame in Sprite Animation
« Reply #5 on: November 30, 2012, 09:14:31 pm »
Will do, thanks!

apbilyk

  • 2D Toolkit
  • Newbie
  • *
  • Posts: 17
    • View Profile
Re: Offset Specific Frame in Sprite Animation
« Reply #6 on: March 18, 2013, 01:01:13 am »
Hey Unikron, I too am interested in per-frame offset controls, and I found this thread.  The other suggestions regnared made sound pretty useful, too.  Is any of this stuff still on your agenda?  Thanks!

unikronsoftware

  • Administrator
  • Hero Member
  • *****
  • Posts: 9709
    • View Profile
Re: Offset Specific Frame in Sprite Animation
« Reply #7 on: March 18, 2013, 01:10:45 am »
Yes it is, but only after 2D Toolkit 2.0 is released.

apbilyk

  • 2D Toolkit
  • Newbie
  • *
  • Posts: 17
    • View Profile
Re: Offset Specific Frame in Sprite Animation
« Reply #8 on: March 18, 2013, 02:56:39 am »
Gotcha. Thanks for the heads up!

cjke.7777

  • 2D Toolkit
  • Newbie
  • *
  • Posts: 4
    • View Profile
Re: Offset Specific Frame in Sprite Animation
« Reply #9 on: October 29, 2013, 01:01:44 am »
Sorry for opening this thread up again after 120 days but it is directly related.

I too am looking for a similar feature. More than happy to role some of my own code to make it work, any suggestions on a starting point. Am I better extending the animator class directly?

unikronsoftware

  • Administrator
  • Hero Member
  • *****
  • Posts: 9709
    • View Profile
Re: Offset Specific Frame in Sprite Animation
« Reply #10 on: October 29, 2013, 10:40:01 am »
The real problem with this (and the reason it isn't implemented yet) is that the animator is linked to the game object, making it really hard to animate "yourself". It is dependent on how you move your sprite, etc. Eg. it won't work if you were using a rigid body on the sprite. Even if you did move yourself using deltas, you'd probably end up drifting eventually.

There is a way to do it though. We laid the groundwork for it in the 2.0 animator. The main thing here is that the animator does NOT need to be attached to the sprite its animating. The default implementation provided with tk2d does require this, but you can write an overridden version that doesn't, quite easily. That way you can keep the physical sprite as a child of the animator, and animate it as required - at that point, all you need is the data stored per animation frame and offset it every frame.

I posted an example here: http://2dtoolkit.com/forum/index.php/topic,2965.0.html
of decoupling the sprite from the animator. That is probably a good place to start if you want to implement this thing were discussing here - you obviously don't need to do the multiple sprite thing it does, but you will know where to start modifying the offsets of the child game object.

mfcas

  • 2D Toolkit
  • Newbie
  • *
  • Posts: 24
    • View Profile
Re: Offset Specific Frame in Sprite Animation
« Reply #11 on: September 17, 2014, 09:12:00 pm »
Any updates on this?

I need to use same sprites for different animations, in which I need them to be anchored differently.

I just hacked together this feature and it seems to be working, but it'd be nice to have it well made and officially supported. I just added a vector to each animation frame, and based on that I offset the sprite's verts, attach points and thumbnail in the animation editor.

Another solution would be to allow sprites with the same UVs in the sprite collection. The name, settings etc. could be different then, but the texture space would be shared.
« Last Edit: September 18, 2014, 01:29:47 am by mfcas »

unikronsoftware

  • Administrator
  • Hero Member
  • *****
  • Posts: 9709
    • View Profile
Re: Offset Specific Frame in Sprite Animation
« Reply #12 on: September 18, 2014, 10:23:56 am »
No, the same stuff applies, though I've slightly warmed to the idea of having an "offset" variable just like "scale" on the sprite. It sounds like an easy thing to add but there are significant permutations to consider for this.

"Another solution would be to allow sprites with the same UVs in the sprite collection. The name, settings etc. could be different then, but the texture space would be shared."
You can already do that. If you add 2 sprites, one with a bit more empty space in it (eg. offset vertically), they would reduce to 1 sprite in the sprite collection. This has been the case for a very very long time.

mfcas

  • 2D Toolkit
  • Newbie
  • *
  • Posts: 24
    • View Profile
Re: Offset Specific Frame in Sprite Animation
« Reply #13 on: September 18, 2014, 10:43:29 am »
Great to know this, thanks. I didn't look carefully enough, if you drop same sprite in the collection editor again then it asks you if you want to clone it.

unikronsoftware

  • Administrator
  • Hero Member
  • *****
  • Posts: 9709
    • View Profile
Re: Offset Specific Frame in Sprite Animation
« Reply #14 on: September 18, 2014, 10:45:05 am »
Yeah, cloning it creates a copy in the sprite collection but not in the atlas :)