Getting a bit stuck with this.. Basically, I have a a project which allows me to add a number of items to a scene and drag them to re-arrange.
I have a
if (itemDragging)
{
_drag3D.updateDrag();
checkCollision();
currentDragObject.position = previousDragPos;
}
and then
private function checkCollision():void
{
var testCount:uint = new uint;
testCount = 1;
for (var i:uint =0; i < currentItemArray.length; i++)
{
var testItem = currentItemArray[i].virtualItem.extra.collisionCube;
//var testItem = cube;
//Dragmesh detects collisions
if (AABBTest(testItem, currentDragMesh))
{
//trace ("object collides with object at ["+i+"]");
trace ("testCounts is " + testCount);
}
else {
trace ("No collision: AABB test = " + AABBTest(testItem, currentDragMesh));
testCount += 1;
trace ("testCounts is " + testCount);
}
if (testCount == currentItemArray.length)
{
previousDragPos = currentDragObject.position;
}
}
}
But strangely it only seems to detec collision on certain sides..
Is there a more elegant way of cycling through items on screen and checking to see if they intersect?