Static target in the srcipt for my Prefab

I have an FPS Character Controller and an Enemy.When The FPScc enters in to the trigger it makes the Enemy prefab invite to the scene and this enemy has a follow script and a target “Transfrom” variable. The problem is if I delete the Enemy from the scene( because I want it to appear if I hit the trigger…) the Transform variable lose the my target and cant invite the prefab. Can I define my target manually in the script?


In the OnTriggerEnter function where you Instantiate the enemy prefab you just need to hand it the new target to follow.

EG. (in C#)

public Object enemyPrefab;
void OnTriggerEnter()
	GameObject enemy = (GameObject) Instantiate(enemyPrefab,,;
	enemy.GetComponent("Follow").target = gameObject.transform;

Warning Untested code that assumes things about your scripts. May not work at all.

Okey you have exaggerated this a little bit :D. Btw I figured out the answer what I want:

  1. public var thePlayer : Transform;
  2. thePlayer = GameObject.Find( “First Person Controller” ).transform;