-
-
Save JohnBrookes/6ceaa634c1afafce15ac to your computer and use it in GitHub Desktop.
Compound child Box collision
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
private function bodyCollisionAdded(e:AWPEvent):void { | |
if (AWPRigidBody(e.target).shape is AWPCollisionObject) { | |
for (var i:uint = 0; i < AWPCompoundShape(e.target.shape).children.length; i++) { | |
//Box collision | |
if (AWPCompoundShape(e.target.shape).children[i].shapeType == AWPCollisionShapeType.BOX_SHAPE) { | |
var mtx:Matrix3D = AWPCompoundShape(e.target.shape).getChildTransform(i).transform.clone(); | |
mtx.invert(); | |
var pos:Vector3D = mtx.transformVector(e.manifoldPoint.localPointA); | |
var d:Vector3D = AWPBoxShape(AWPCompoundShape(e.target.shape).children[i]).dimensions; | |
if (pos.x >= -d.x && pos.x <= d.x && pos.y >= -d.y && pos.y <= d.y && pos.z >= -d.z && pos.z <= d.z) { | |
trace(i + " Should be the index of the compound child"); | |
} | |
} | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment