• Runtimes
  • Handling Collisions with Spine in XNA?

So, I have an animation using Spine, easy enough... But How do I manage to handle collisions now with XNA? I was thinking on drawing a rectangle over the animation and use the usual intersects method, but that doesn't seem like the best way... So I'd like to listen to some opinions if that's ok.

Thanks in advance

Related Discussions
...
  • Düzenlendi

That's probably the most efficient way to do it. If you wan't to get "crazy" you can also use the bounds of each image or draw a bounding box for each bone, but this is quite a bit more to calculate.

7 gün sonra

There really isn't a "best" way. Here are three common methods (which have nothing to do with Spine):

1) If it will work for your game, the simplest method is just axis-aligned bounding boxes. (Exactly what you suggested.)
2) You can use several rectangles (or circles, which are much faster) to make the collision shapes, and test those.
3) Finally, you could create a collision polygon for each character, and use the separating axis theorem to find out if they are colliding. I wrote a bit about this method a long time ago here: http://thirdpartyninjas.com/blog/2010/0 ... on-update/ (Read the linked references. They do a much better job explaining it than my code would.)

Unless you're planning something pretty complicated, one of those should be perfect for what you need.

6 gün sonra

Spine has a bounding box attachment, which is a polygon that is transformed by the bones. See the SkeletonBounds class.