filbs111 / box2d-learning

0 stars 0 forks source link

player tunneling #25

Open filbs111 opened 7 years ago

filbs111 commented 7 years ago

allow player vehicle to tunnel through landscape. guess can do this by turning off box2d interaction between vehicle and landscape, and for resistance, might calculate volume of landscape overlapping player body, and use that to set drag. might also look to centre of mass of overlapping landscape, and cross with player velocity to give a player angular velocity to decay towards.

aim to have mechanics reminiscent of death worm games.

then can try a player object like a drill rocket, that can land on landscape on its base (nose up), and also drill through the landscape.

filbs111 commented 7 years ago

possibly box2d can be used directly in preSolve to find/estimate overlap. to make a version which should work, 1st try implementing using clipper to find overlap polygon.

there is a method to calculate area of shape https://sourceforge.net/p/jsclipper/wiki/documentation/#clipperlibclipperarea this can then be used for simple linear drag

suprisingly, can't find a method to calc centre of mass of an object. this should be trivial to implement though.

todo 1st step - display overlap shape each frame.