Ive been trying to port a physexplosion function from C to AS3 and im getting a bit stuck and i was hoping that someone could help me out .
Here is my code so far,
private function PhysExplosion(locationPnt, Radius, Force)
{
var Sector:b2AABB;
Sector.lowerBound.Set(locationPnt.x-Radius, locationPnt.y-Radius);
Sector.upperBound.Set(locationPnt.x+Radius, locationPnt.y+Radius);
var k_bufferSize:Number = 10;
var buffer:Array = new Array(k_bufferSize);
var count:int = m_world.Query(Sector, buffer, k_bufferSize);
for (var i:int = 0; i < count; i++)
{
var Body:b2Body = buffer*.GetBody();
var BodyPos:b2Vec2 = Body.GetWorldCenter();
//ERROR1------------------------------------------------------------------------------------
var HitVector:b2Vec2 = (BodyPos.x - locationPnt.x,BodyPos.y - locationPnt.y);
//-------------------------------------------------------------------------------------------
var Distance = HitVector.Normalize(); //Makes a 1 unit length vector from HitVector
if ((Body.IsDynamic())&&(Distance<=Radius))
{
var HitForce = (Radius-Distance) * Force; //TODO: This is linear, but that's not realistic.
//ERROR2-----------------------------------------------------------------------------------
Body.ApplyImpulse(HitForce * HitVector, Body.GetWorldCenter());
//------------------------------------------------------------------------------------------
};
}
};
My errors seem to be with declaring the hitVector and applying it. Any help would be greatly apreciated