Animation and instantiate problem (script attached)

Hello fellow Unity users, hope everyone is doing great. Wondering if anyone has run into this issue before? I have the script below attached to a cube above the player character. The enemy prefabs spawn perfectly, at random locations around the player when the original prefab has it’s animation component disabled but as soon as I enable animation, the enemy prefabs all spawn in the same location. Does the animation component interfere with the Random.Range calculations? Looks like it does.

Thanks for the help.

//////////////////////////////////////////////////////////////
//
//  EnemyGenerator.js
//
//////////////////////////////////////////////////////////////
//
// Script that randomly generates enemies around player
//
//////////////////////////////////////////////////////////////

var linkToEnemyPrefab : Transform;
var CollisionTest : Transform;

private var enemyCount : int = 0;

function Start()
{
	var linkToEnemyPrefab = GameObject.Find("Enemy/Enemy");
	var CollisionCube = GameObject.Find("First Person Tilt Controls/Player/CollisionTest");
}

function SpawnEnemies()
{
	var SpawnBoxX = CollisionTest.transform.position.x + (Random.Range(-20, 20));
	var SpawnBoxZ = CollisionTest.transform.position.z + (Random.Range(-20, 20));
	var enemyYPosition = 1;
	newEnemy = Instantiate(linkToEnemyPrefab, Vector3(SpawnBoxX, enemyYPosition, SpawnBoxZ), Quaternion.Euler(0, (Random.Range(360, -360)), 0));
	enemyCount++;		
}

function Update()
{
	if (enemyCount < 11)
		SpawnEnemies();
}

I’ll bump this. Any ideas? Is this a known bug?

You need to Parent the animated enemies to an Empty Game Object and then spawn that. The the animations will be in local space and will not reset back to the world origin point.

aNTeNNa trEe, I owe you a drink! That tip fixed the problem. Thank you, hope this helps others in the situation.