Complex Question In Targetin System & rocket shoot

hi. working on a game project with flying aircrafts and i have created a targeting system and let me explain it with words because its a little bit big script for you to read just for one question.so i have a trigger and when a there are enemy aircrafts their transforms are saved in a generic list ( temporary targets ) so i have 2 vars targetlocking & targetlocked and in the first time when its starts targeting target is in targetlocking and after 4 seconds it goes to targetlocked. the targeting system works perfect with no bugs but im explaining it to you because you need to know it in order to help me in my problem, so i have another script that shoots rockets at enemies and especialy when target is locked the the rocket is following the enemy and here is my problem if i shoot the target and i lose my target the rocket is not following the target anymore but i want as long as the rocket was launched when target was locked then it follows the target no matter what
here are the 2 scripts

using UnityEngine;
using System.Collections;
using System.Collections.Generic;

public class TargetDetector : MonoBehaviour {
	
	public static Transform TargetLocking;
	public static Transform TargetLocked;
	
	List<Transform> TemporaryTargets = new List<Transform>(); 
	
	
	void Start(){
	InvokeRepeating("CheckTempTargets",1,1);
	
	}

void OnTriggerEnter(Collider other) {
		Debug.Log("Somthing Entered in the trigger");
		
		if (other.tag == "Enemy") 
		{
			TemporaryTargets.Add(other.transform);
		}
		
		if (TemporaryTargets.Count == 0 && TargetLocking == null && TargetLocked == null)
		{
			StartCoroutine("takeTarget",other.transform);
		}
		
	}
	
void OnTriggerStay(Collider other) {
		
		if (TemporaryTargets.Count > 0 && TargetLocking == null && TargetLocked == null)
		{
			StartCoroutine("takeTarget",TemporaryTargets.Find(delegate(Transform obj) {return obj;}) );
			
		}
	
	}
	

void OnTriggerExit(Collider other){
		
		
		if (other.tag == "Enemy")
		{
			TemporaryTargets.Remove(other.transform);
			Debug.Log("Removed a Temporary Target From List");
		}
		
		if(other.transform == TargetLocked)
		{
			TargetLocked = null;
		}
		if(other.transform == TargetLocking)
		{
			TargetLocking = null;
			StopCoroutine("takeTarget");
		}
	
	}
	
	
	void CheckTempTargets()
	{
		Debug.Log (TemporaryTargets.Count);
	}
	
	IEnumerator takeTarget(Transform other)
	{
		Debug.Log("Started the Target Function");
		TargetLocking = other;
		yield return new WaitForSeconds(3);
		TargetLocked = TargetLocking;
		TargetLocking = null;
		Debug.Log("locked Target");
		
	}
}

using UnityEngine;
using System.Collections;

public class RocketScript : MonoBehaviour {
	public float damping;
	public Transform ExplosionParticles;

	
	
	// Update is called once per frame
	void Update () {
		
		if(TargetDetector.TargetLocked)
		{
			transform.LookAt(TargetDetector.TargetLocked);
			
		}
		Destroy(gameObject,5);
	
	}
	
	void OnCollisionEnter(Collision collision)
	{
		if (collision.gameObject.tag == "Enemy")
		{
			Destroy(gameObject);
			Instantiate(ExplosionParticles,transform.position,transform.rotation);
		}
	}
}

possibly it happens because you “delete” your locked target after it left the collision here:

if(other.transform == TargetLocked)
    {
       TargetLocked = null;
    }

you either rewrite it in some way, or simply add an extra variable to your rocket script and after creating the rocket simply add the target, the rocket follows, there, this way you can have multiple rockets tracking multiple targets, and you don’t need to be afraid, that locking a new target would hijack your rocket

it wont work because this is the update function and when targetlocked is going to be null the other variable will get null too , so i found another way and its solved but im posting it if any other wants to see it so i created a function with a boolean

IEnumerator RocketShooted()
	{
		print ("RocketShooted Function Called");
	 	rocketShooted = true;
		yield return new WaitForSeconds(5);
		rocketShooted = false;
		
	}

and in the targetdetector script changed this

new

if(other.transform == TargetLocked)
		{
			if(RocketSpawnSource.rocketShooted == true)
			{
				StartCoroutine("DelayTargetRemove");	
			}
			else
			{
				TargetLocked = null;
			}

old

 if(other.transform == TargetLocked)
       {
         TargetLocked = null;
       }