SplatJS / splat-ecs

MIT License
12 stars 3 forks source link

Add collision resolution #19

Open AlexBezuska opened 8 years ago

AlexBezuska commented 8 years ago

Axis Aligned Bounding Box (direct replacement for the one we use commonly) https://www.npmjs.com/package/aabb-2d https://www.npmjs.com/package/aabb-3d https://www.npmjs.com/package/aabb

AlexBezuska commented 8 years ago

Lots of other interesting collision modules: https://www.npmjs.com/search?q=collision

CaldwellYSR commented 8 years ago

How would we differentiate collisions and triggers? Would we create a new triggers component to handle non-physical collisions or however you say that?

CaldwellYSR commented 8 years ago

https://www.npmjs.com/package/sat

This package looks pretty cool. Support circles and polygons

CaldwellYSR commented 8 years ago

Would there be any interest in having a collision detection system that supports shapes besides rectangles? I imagine it would be a bear to overhaul the collision system but I think having other polygons would be pretty nice.

ericlathrop commented 8 years ago

Yes. It's a lot of work, though. You'll want to Google separating axis theorem. There might be an npm module for it.

On March 28, 2016 2:40:56 PM EDT, Matthew Caldwell notifications@github.com wrote:

Would there be any interest in having a collision detection system that supports shapes besides rectangles? I imagine it would be a bear to overhaul the collision system but I think having other polygons would be pretty nice.


You are receiving this because you are subscribed to this thread. Reply to this email directly or view it on GitHub: https://github.com/SplatJS/splat-ecs/issues/19#issuecomment-202524124

CaldwellYSR commented 8 years ago

Yeah the package I posted a while back was an SAT package. Looked simple enough.

CaldwellYSR commented 8 years ago

https://github.com/CaldwellYSR/splat-ecs/blob/collisions/lib/systems/box-collider.js#L31

This is using SAT to replace the box-collider but it's got a couple problems. It seems to report collisions correctly for the most part but I was also finding situations where idA and idB were the same like it was reporting collisions between the same entity. On top of that, I kept getting (cannot find "collisions" of undefined) which I think was happening when an entity was being destroyed in the middle of trying to update the collisions array, I could be wrong though.

I think I need a faster way to test collisions between all the elements besides that double for loop.