Hello Guest

Author Topic: Sprite Animations + Collider(s)  (Read 9111 times)

kwhittington

  • 2D Toolkit
  • Newbie
  • *
  • Posts: 10
    • View Profile
Sprite Animations + Collider(s)
« on: July 12, 2013, 08:19:34 pm »
Hi all,

I just recently purchased the 2D Toolkit to make a action-platformer game with.

I tore through the Quick-Start guide already but couldn't find a good reference for handling sprite animations with colliders.
I gave all the sprites in the animations custom polygon colliders but the result at runtime is a Mesh Error message, ~="mesh cannot be applied". My first question would be if anyone knows if this is due to the frames having different polygon colliders?

In previous engines, it wasn't possible to change the physical bodies of objects at run time w/o causing a world of hurt from the Math Gods, but I can't find anything explicitly stating that for 2DTK.

Also, objects in the game will need to have multiple sets of colliders: 1 (or 2) for location and hitbox, then another for hurtboxes during attacks. Is it possible to accomplish this with 2DTK and Unity's default physics engine or should I look into other 3rd party software?

Thanks!

unikronsoftware

  • Administrator
  • Hero Member
  • *****
  • Posts: 9709
    • View Profile
Re: Sprite Animations + Collider(s)
« Reply #1 on: July 13, 2013, 03:02:48 pm »
You shouldn't change shape of colliders on rigidbodies, of course. It does work but it can end up doing some nasty things ;)

Animated hitboxes are fine, of course, but the current tk2d only supports one collider per sprite. With 2.1 beta, you can attach colliders to attach points and animate attachpoints per frame = multiple hitboxes.

kwhittington

  • 2D Toolkit
  • Newbie
  • *
  • Posts: 10
    • View Profile
Re: Sprite Animations + Collider(s)
« Reply #2 on: July 13, 2013, 03:10:33 pm »
Sweet, I'm off to download 2.1 beta then.

Thanks!

kwhittington

  • 2D Toolkit
  • Newbie
  • *
  • Posts: 10
    • View Profile
Re: Sprite Animations + Collider(s)
« Reply #3 on: July 13, 2013, 08:30:16 pm »
Do you guys have a good resource/doc for the attachpoints feature laying around anywhere?

Thanks!

unikronsoftware

  • Administrator
  • Hero Member
  • *****
  • Posts: 9709
    • View Profile
Re: Sprite Animations + Collider(s)
« Reply #4 on: July 13, 2013, 09:08:44 pm »
Not yet, the 2.1 docs are still being worked on, hence it still being in beta. There isn't a demo ready either :(
Should be straightforward to use - in the sprite collection editor, you'll see a little "AttachPoints" tab down the bottom. Click on it and it should be obvious enough how to create and position these. You do that on all your frames of animation, then on the sprite + animator, you add a tk2dAttachPoint behaviour to it. That should be it.

kwhittington

  • 2D Toolkit
  • Newbie
  • *
  • Posts: 10
    • View Profile
Re: Sprite Animations + Collider(s)
« Reply #5 on: July 15, 2013, 04:35:04 am »
I've been playing around with the attachpoints but can't figure out how to use the tools to attach anything but sprites to them.
Is there anything in the toolset I might be overlooking or will I need to attach the colliders via code?

Thanks again for the info!

unikronsoftware

  • Administrator
  • Hero Member
  • *****
  • Posts: 9709
    • View Profile
Re: Sprite Animations + Collider(s)
« Reply #6 on: July 15, 2013, 11:39:45 am »
Once you've created the attach point in the scene, you can attach anything to it. Eg. attach a default Unity 3d box to it, remove or disable the meshrenderer component - you will have a collider there now.

kwhittington

  • 2D Toolkit
  • Newbie
  • *
  • Posts: 10
    • View Profile
Re: Sprite Animations + Collider(s)
« Reply #7 on: July 15, 2013, 05:09:22 pm »
Thanks but I was asking more about how to attach something to the attach point.
The only GUI tools I can find revolve around creating and rotating them, and then previewing what it would be like to attach sprites to them. If you were going to add something else to them, like a Box, is there a component in the GUI to accomplish this or do you need to add it do the object's custom script?

unikronsoftware

  • Administrator
  • Hero Member
  • *****
  • Posts: 9709
    • View Profile
Re: Sprite Animations + Collider(s)
« Reply #8 on: July 15, 2013, 05:41:45 pm »
The preview doesn't actually attach anything to it - you're still responsible for attaching what you need to on the sprite. The next beta update will have a simple sample, with an animated sprite holding a particle system. Maybe that'll help explain this properly.

kwhittington

  • 2D Toolkit
  • Newbie
  • *
  • Posts: 10
    • View Profile
Re: Sprite Animations + Collider(s)
« Reply #9 on: July 16, 2013, 12:37:03 am »
So sorry, I was adding the behavior incorrectly. I mistakingly took your explanation to mean I should add the AttackPoint behavior to the SpriteAnimation, not the Sprite. Moved the behavior to the sprite and I see exactly what you mean now, thanks for bearing with my terrible comprehension skills haha.

Thanks again, looking forward to that example!

unikronsoftware

  • Administrator
  • Hero Member
  • *****
  • Posts: 9709
    • View Profile
Re: Sprite Animations + Collider(s)
« Reply #10 on: July 16, 2013, 10:31:35 am »
The example is in beta 2 which is now available. Its a really simple sample, but should help clear things up if they aren't already clear.