Creating objects with multiple hit boxes

95 views
Skip to first unread message

Robert Wenham

unread,
Feb 4, 2016, 4:26:55 PM2/4/16
to Crafty
Hi Crafty people,

im working on a game which has a lot of concave objects.
I was looking at using crafty but I can't find any information on how to use concave hit boxes, or at least simulate one by combining multiple hit boxes.

Can anyone point me in the right direction?


starwed

unread,
Feb 6, 2016, 10:36:10 AM2/6/16
to Crafty
Crafty uses SAT collision detection, so as you suspect it only works for convex objects.

If you want to add multiple hit boxes, you can create an additional entity for each, add a hit box to it, and use the .attach() method to have its motion match the main entity.  You'd then have to communicate between these child entities and the parent to get collisions working properly.

This probably won't work too well if you want reasonable physics, but if it's just for checking e.g. whether an entity gets hit by a projectile it should be fine.

mucaho

unread,
Mar 1, 2016, 10:36:02 AM3/1/16
to Crafty
Based on starweds answer made a small example for similar question posted on stackoverflow: http://stackoverflow.com/q/34992200/3041008
Reply all
Reply to author
Forward
0 new messages