One thing I use is line intersection. You know, putting those simultaneous equations to use that they taught in school. It's one of the few uses of simultaneous equations.
Fun AI:
So what I do is I start Slerping towards the target. Then use Dot-product to see if I am at least in a 0-45 degree angle(This is based on speed of target) then I would calculate a intersect point using simultaneous equations.
Hit rate +/- 60% of the time.
Hard AI:
My fun AI was adapted from the "Dot-Product Intercepting". With a quick search I found this tutorial, that explains it very well: http://danikgames.com/blog/how-to-intersect-a-moving-target-in-2d/ It's easy to follow. It also has a 3D link: http://danikgames.com/blog/moving-target-intercept-in-3d/
As always, if you plan to learn it, first do the 2D before moving to 3D.
So the reason for my "Fun" version is that the AI is too smart. It hits with a +/-90% rate; especially when it can move towards the intercept point; then it is a 100% rate.
I almost forgot. I have a lerp version:
void OnTriggerStay(Collider Other){
if(Other.CompareTag("Player")){
//Other speed as a percentage
float SpeedPer = Other.GetComponent<Rigidbody> ().velocity.magnitude /
Other.GetComponent<ShipEngine> ().StatsPlug.MaxSpeed;
//Target ship or lead based on ship speed
NewTargetPosition = Vector3.Lerp(Other.transform.position,
Other.GetComponent<ShipEngine>().LeadTargetPoint, SpeedPer);
//The larger the difference between the target-
DifBetweenTargets = (Vector3.Dot (LastTargetPosition.normalized,
(NewTargetPosition - this.transform.position).normalized) + 1f) / 2f;
//-the slower it turns to face the new target
if (LockTarget < 1f) {
LockTarget += DifBetweenTargets* Time.fixedDeltaTime;
}
//lerp between old and new exponentially as difference shrinks
Offset = Vector3.Lerp(LastTargetPosition, NewTargetPosition - this.transform.position, LockTarget);
this.transform.rotation = Quaternion.LookRotation (Offset);
}
}
I am very proud of this one even if it is only a prototype. It targets objects in sight quickly and objects behind it slowly. This gives it a "tracking target" feel.
Hit rate = +/- 50%
You can improve the hit rate with line intersection.