public override void Execute(AIBrain brain) { Vector3?hitNormal; Vector3?hitPos = brain.ObstacleAhead(lookAhead, out hitNormal); if (hitPos.HasValue && hitNormal.HasValue) { brain.LookAt(hitPos.Value + hitNormal.Value.normalized * normalMultiplier, true); } }
public override bool Evaluate(AIBrain brain, params ConditionParam[] condParams) { try { if (condParams.Length > 1) { lookAhead = condParams[0].AsFloat(); } } catch (Exception e) { Debug.LogWarningFormat("Improper condParams. {0}", e.Message); } return(brain.ObstacleAhead(lookAhead * brain.ship.thrustVelocity.magnitude) != null); }
public static Vector3?ObstacleAhead(this AIBrain brain, float maxDistance) { Vector3?normal; return(brain.ObstacleAhead(maxDistance, out normal)); }