New to Unity.... Need some help with correct syntax on accessing a script variable in a prefab to which I have a transform handle.
I have code below in a "GameMaster" script. This script instantiates a prefab with a Transform handle. I want to get at a script variable that is in a script that is part of the same prefab.
The line 'badGuy.Enemy1_AI.EnemyLevel = badEnemyLevel;' in the GameMaster script fails with 'Enemy1_AI is not member of unity.transform'.
I understand this since I have declared badGuy as a Transform which is a sub-component. What would be the correct syntax to access a script variable (Enemy1_AI is the script) when I have a reference to a Transfrom that is part of the prefab?
// GameMaster.js
var enemy1 : Transform; var badGuy : Transform;
var badEnemyLevel : int =1;
badGuy = Instantiate ( enemy1, Vector3 ( (Random.value * 400) - 200, 0, -2460), Quaternion.identity);
badGuy.Enemy1_AI.EnemyLevel = badEnemyLevel;
// Enemy1_AI.js
static var EnemyLevel : int;