Hello Guest

Author Topic: Using Polygon Colliders in Animated Sprites. Collider doesnt update.  (Read 8679 times)

derricklevy

  • 2D Toolkit
  • Newbie
  • *
  • Posts: 2
    • View Profile
I am trying to use Polygon colliders for certain animation clips in my animation collection and box colliders for certain other clips. However, when the animation clip changes, the collider is not automatically updated to the collider defined for the new clip. When using Box Colliders  exclusivey, this all works. Why doesnt it work with polygon colliders? Can I use multiple box colliders on a sprite to get a better approximation of the actual collision volume of the sprite as recommended in the Unity manual for complex shapes?

Thanks,
Derrick

unikronsoftware

  • Administrator
  • Hero Member
  • *****
  • Posts: 9709
    • View Profile
Re: Using Polygon Colliders in Animated Sprites. Collider doesnt update.
« Reply #1 on: March 27, 2013, 12:11:40 am »
Hi Derrick,

You can't animate polygon colliders. Performance suffers really badly when you do this, as the mesh will need to be reconstructed every frame. Reconstructing the mesh reconstructs some internal Physx representations of the mesh, and that is a pretty CPU intensive process.

The best option is to use multiple box colliders to represent the shape, but this isn't yet possible in the current version. This will be addressed in a future update.

There are ways to implement this without writing complex code, though. Let me know if you'd like me to go through the options, and I will, but if you can wait, this will be a core feature fairly soon.



Evil-Dog

  • 2D Toolkit
  • Newbie
  • *
  • Posts: 38
    • View Profile
I would love to hear the options for this, I'm working on a fighting game and I'd like to be able to have animated colliderS and triggers over the animated sprites, commonly known as hurt boxes, damage boxes, etc

Would it be a dumb idea if I wanted to have say 3 colliders per frame to simply duplicate the animations 2 more times and animate the set of colliders, play all 3 anims at the same time but hide the visual component of the 2 extra animations?

EDIT: Like I said on another thread, I had this solution in mind before checking how TK2D worked, seeing how the colliders are in the collection, what I said makes little sense.  But you mentioned the multi-collider support is planned which is awesome!

If I may suggest, a way to identify the colliders with tags or something, I believe you'll let people make multiple box colliders for exemple cause they're faster than mesh colliders.  and so I could easily imagine using many boxes for hurt boxes and many other boxes for hit boxes, etc, many boxes for many usage.
Anyway thanks for the update!
« Last Edit: May 15, 2013, 05:26:58 am by Evil-Dog »