Quantcast
Channel: Pixi.js Latest Topics
Viewing all articles
Browse latest Browse all 3979

Better Collision Detection

$
0
0

Currently, the Sprites in my game only have rectangular collision detection, but more complex shapes for their hitArea. This makes drag & drop very nice but I am wondering if the same is possible for collision detection. Somehow, Scratch has this ability. As shown here, even for shapes where a hull would not be very good, the collision detection is still perfect. Anyone have an idea if this can be done in PIXI? Or am I just limited to rectangular collision detection?

 

For example, a sample sprite I have looks like this:

image.png.7eda77484fccc951639619b82a8610b9.png

 

And the hitArea I generated looks like this:

image.png.caa25823e23e429fd8741e5be45e25d7.png

 

The hit area is represented as an array of polygons:

image.png.ddac6a85101a9d0641adc487be4de1fa.png

 

Assuming each of my sprites also has a hitArea of N polygons, is there a library I can use to detect collision between the two?  I looked at the Separate Axis Theorem, but that seems to only work when each sprite can be represented as a single polygon. However, mine are represented as many polygons together.

 

Any suggestions? 


Viewing all articles
Browse latest Browse all 3979

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>