I have a different script which sets and changes this scripts “turretSkill” gameobject. Then in this script I would like to set the component. “TuuretControl” is a script attached to each “turretSkill” object that will be set in this gameobject.
public GameObject turretSkill;
private TurretControl turretControl;
void Update()
{
if(turretSkill)
{
print ("Have turretSkill");
turretControl = turretSkill.GetComponent<TurretControl> ();
if(turretControl) //will not assign this variable
{
print ("Have turretControl"); //this will not print out
}
}
}
But this is not working. The “turretSkill” GameObject is a prefab and is not instantiated in the scene. Just need this to grab certain variable amounts for a info box that displays turrets damage and etc.