Stop chasing me if you can't see me at the end of your path
This commit is contained in:
@@ -717,15 +717,9 @@ var AISprite = function(game, x, y, key, frame) {
|
|||||||
if ( hasState(this, STATE_ALERTED) )
|
if ( hasState(this, STATE_ALERTED) )
|
||||||
vd = vd * 2;
|
vd = vd * 2;
|
||||||
|
|
||||||
var xd = (spr.x - this.x);
|
|
||||||
if ( xd < 0 )
|
|
||||||
xd = -(xd);
|
|
||||||
var yd = (spr.y - this.y);
|
|
||||||
if ( yd < 0 )
|
|
||||||
yd = -(yd);
|
|
||||||
|
|
||||||
var hyp = Math.sqrt(Number(xd * xd) + Number(yd * yd));
|
var distance = (new Phaser.Line(spr.x, spr.y, this.x, this.y).length);
|
||||||
if ( hyp > vd ) {
|
if ( distance > vd ) {
|
||||||
console.log("Target is outside my view distance");
|
console.log("Target is outside my view distance");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user