Moving Circle vs Moving Circle

I’ve been working on a tile-engine lately and I’ve hit a bit of a snag when doing object to object collision. My moving objects are defined as cylinders, but I’m having trouble with the two dimensional circle part of it, so consider this a circle to circle problem. I can calculate the exact time and point of the collision, that’s not the problem, but currently the physics in my engine are, that an object can move in a dimension if it isn’t blocked in that dimension. That means that if I would diagonally jump into a horizontal wall, only the y-dimension would be blocked, so I stop moving in the y dimension, but keep moving in the x and z dimensions. If that doesn’t make sense, try the link to the current build at the end of this post.

This is the current code I’m using.


private function movingObjektBlock(Red:RigidBody, Blue:RigidBody, LINE:Line):Number { 
    var RR:Number = Red.radius+Blue.radius; 
    var dX:Number = Red.x-Blue.x; 
    var dY:Number = Red.y-Blue.y; 
    // 
    var Vx:Number = Red.Vl.x-Blue.Vl.x; 
    var Vy:Number = Red.Vl.y-Blue.Vl.y; 
    // 
    // 
    var a = Vx*Vx+Vy*Vy; 
    var b = 2*dX*Vx+2*dY*Vy; 
    var c = dX*dX+dY*dY-(RR*RR); 
    // 
    var Ta = (-b+Math.sqrt(b*b-(4*a*c)))/(2*a); 
    var Tb = (-b-Math.sqrt(b*b-(4*a*c)))/(2*a); 
    // 
    var T1:Number 
    var T2:Number 
    if (Ta<Tb) { 
        T1 = Ta 
        T2 = Tb 
    } else { 
        T1 = Tb 
        T2 = Ta 
    } 
    // 
    var z1:Number = LINE.getZforT(T1) 
    var z2:Number = LINE.getZforT(T2) 
    var T:Number = -1 
    if ((z1 > Blue.z && z1 < Blue.z + Blue.height) || (z1 + Red.height > Blue.z && z1 + Red.height < Blue.z + Blue.height) || (z1 < Blue.z && z1 + Red.height > Blue.z + Blue.height)) { 
        //Collision 
        T = T1 
    } else if ((z2 > Blue.z && z2 < Blue.z + Blue.height) || (z2 + Red.height > Blue.z && z2 + Red.height < Blue.z + Blue.height) || (z2 < Blue.z && z2 + Red.height > Blue.z + Blue.height)) { 
        //Collision 
        T = T2 
    } 
    // 
    // 
    if (T>0 && T<1) { 
        return (T); 
    } else { 
        return (-1); 
    } 
} 

The problem with just one time is, that I wouldn’t know the time for the individual dimensions. What I was thinking of, is moving the circles to the state of collision. Draw a line from centre to centre and get the left and right normal of that line. This would be the virtual dimension that the other circle isn’t blocking. If I project the remaining movement vector on that line, would that be the solution to my problem?

I’m a bit fried at the moment so any other suggestions are welcome.

CURRENT BUILD

Arrows to move, space to jump
c = fire
x = incendary grenade
z = frag grenade