private SteeringOut Evade(MovingAgent targetAgent) { Vector2 toAgent = targetAgent.Position - _owner.Position; float lookAheadTime = toAgent.magnitude / (_owner.Velocity + targetAgent.Velocity); return(Flee(targetAgent.FuturePosition(lookAheadTime))); }
private SteeringOut Pursuit(MovingAgent targetAgent) { Vector2 toAgent = targetAgent.Position - _owner.Position; float deltaHeadingAngle = Utils.AbsDeltaAngle(_owner.DegreeHeading(), targetAgent.DegreeHeading()); float deltaAngle2Agent = Utils.AbsDeltaAngle(_owner.DegreeHeading(), Utils.Vector2Angle(toAgent)); // If owner and the target agent head to each other // -> Seek straight to target agent if (deltaAngle2Agent < 10 && deltaHeadingAngle < 10) { return(Seek(targetAgent.Position)); } //Else Seek toward the predicted future position float lookAheadTime = toAgent.magnitude / (_owner.Velocity + targetAgent.Velocity); return(Seek(targetAgent.FuturePosition(lookAheadTime))); }