I’m trying to instantiate a clone that follows a GameObject with an offset. As this GameObject is disabled and enabled in game I’m creating it in OnEnable like this:
void OnEnable() {
CreateClone();
}
private void CreateClone() {
GameObject clone = Instantiate(gameObject);
}
The problem is that this way it loops infinitely because clone will have the same script that will generate a new clone and so on… I tried disabling script and enabling after but it had no effect.
How can I get only one clone each time the object is enabled?