I've been thinking about this for a week or so but still can't figure out what's causing the issue. It's happening on arbitrary times, locations, angles.. for no apparent reason.

There it only happened on that marked angle.
The code is simply as follows,
Here's how I draw the ray, though I'm sure that it's nothing to do with this issue.
Note: Game has no gravity

There it only happened on that marked angle.
The code is simply as follows,
Code: Select all
private function onEnterFrame(e:Event):void
{
// raycast from enemy to player
var enemyPos:b2Vec2 = enemy.body.GetWorldCenter();
var playerPos:b2Vec2 = player.body.GetWorldCenter();
world.RayCast(callback, enemyPos, playerPos);
}
private function callback(fixture:b2Fixture, point:b2Vec2, normal:b2Vec2, fraction:Number):Number
{
_fixture = fixture;
_intersection = point;
return fraction;
}
Here's how I draw the ray, though I'm sure that it's nothing to do with this issue.
Code: Select all
// draw rays
rays.graphics.lineStyle(1, Color.RED);
rays.graphics.moveTo(To.px(enemyPos.x), To.px(enemyPos.y));
rays.graphics.lineTo(To.px(_intersection.x) , To.px(_intersection.y));
Note: Game has no gravity