Question

In my game, there will be collision between two relatively small objects. There need only be accurate detection of collision and what the object has collided with.

The specific scenario is this: Two characters will have swords, and I need to be able to detect when two swords collide. This is made complicated by the fact that they will be moving around and are rotated quite often.

.hitTestObject() works fine with rectangles, which is essentially what I'm checking, but once they begin to rotate this becomes inaccurate due to the 'box' of detection, throwing this out the window.

I've considered raycasting since the swords are essentially decorated lines, but that seems like a lot of trouble to go through when I don't need to know where the point of collision is.

Am I going to have to use a custom library, raycasting, or is there another solution?

Était-ce utile?

La solution

Depending on the level of accuracy, your swords could be represented by two lines and you just need to find if they cross. this might do it for you. http://keith-hair.net/blog/2008/08/04/find-intersection-point-of-two-lines-in-as3/

Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top