I'm getting really frustrated here. I've tried every solution there is to get the angle between two objects
and I get some angles that don't correspond to anything, or indicate any relationship of positioning.
function angleCalc (x1:Number, y1:Number, x2:Number, y2:Number):Number
var dx:Number = x2 - x1;
var dy:Number = y2 - y1;
var j:Number = Math.atan2(dy,dx) * Constants.RADIANS_TO_DEGREES;
var targetAngle:Number = angleCalc(car.GetPosition().x * Constants.PIXELS_TO_METRE,
(car.GetPosition().y * Constants.PIXELS_TO_METRE) - 20,
bombObject.body.GetPosition().x * Constants.PIXELS_TO_METRE,
bombObject.body.GetPosition().y * Constants.PIXELS_TO_METRE);
The angle ends up making no sense, being the opposite of where it's supposed to be.
I convert the angle to a vector and impulse it
var impulse = new b2Vec2(Math.cos(targetAngle) * 30, Math.sin(targetAngle) * 30);
This is probably a failure of Flash, it fails it so many ways.
Discuss issues specific to the Flash/AS3 port of Box2D
1 post • Page 1 of 1
Who is online
Users browsing this forum: Bing [Bot] and 2 guests