I have created a spawner that spawns clones of my enemy prefab the problem i face is that i have the enemy moving towards my object of choice but when they spawn they do not move towards the object. if i place them in the scene and apply the object for them to target they start moving towards it perfectly but they do not from the spawner here is what happens.
LINK TO MY IMAGE OR LOOK AT ATTACHED FILES >>>> http://imgur.com/DxBZFQ1
And here is my code for moving towards the chest
var target: Transform;
var startTime;
var timer1: int;
var timingOn: boolean;
var GetReadyButton: boolean;
var font : Font;
function Start()
{
}
function Update()
{
if(Input.GetButton("StartWave"))
{
timingOn = true;
startTime = Time.time; //time starter
}
if (timingOn)
{
TimerStart();
}
if(!target)
{
target = GameObject.FindWithTag("Chest").Transform;
return;
}
}
function OnGUI ()
{
GUI.skin.label.font = font;
GUI.Label (Rect (400, 40, 100, 20),"Press G To Start"); //First Text to tell player to press g to start
if(Input.GetButton("StartWave"))
{
GetReadyButton = true;
}
if(GetReadyButton)
{
GUI.Label (Rect (415, 55, 100, 20),"10 Seconds");
}
}
function TimerStart()
{
timer1 = Time.time; //Set time
if(timer1 - startTime >= 10)
{
//Debug.Log ("Timer finished, spawn now");
GetComponent(NavMeshAgent).destination = target.position;
//target = GameObject.FindWithTag("Chest").Transform;
}
}
I Hope someone can fully solve this because i have been stuck on this for awhile now ![]()
Thank you
