Hey guys,
In short my enemy is instantiating with a script in which a GameObject variable is created empty when I always want it to be the same. How can i make each enemy spawn with the GameObject filled in correctly each time?
Thanks in advance!
More Details if necessary-
The script below is on the enemy and makes it seek out my character.
But when it instantiates an enemy clone, the variable “agent : NavMeshAgent” is empty. How can i assign it to always be my character GameObject?
Any help would be great.
Here is the code on the enemy (working fine originally on character)…
var dude : Transform;
static var agent : NavMeshAgent;
function Start ()
{
agent.destination = dude.transform.position;
}
function Update ()
{
CheckLocation();
}
function CheckLocation()
{
agent.destination = dude.transform.position;
}