FSM on duplicates of same object
I have created a few State Machine classes using Animator controller. The problem i'm having is that i don't know how to make the FSM refer to another instance of the same object. For example, in the FSM class i'm referring to the object's components in ways such as: zombieObject = GameObject.Find ("Zombie");
However, when a duplicate of this prefab is made, the name for the new one is Zombie (1), Zombie (2) etc.
How can i refer to the new object in the FSM class? I tried some ways but couldn't because the FSM class can't be added to the prefab (preventing reference to gameObject) since it derives from StateMachineBehaviour and not MonoBehaviour. I also can't reassign the component references in the FSM class since it throws an error as their instances are made as soon as the duplicate is made, or throws some error for some reason.
Answer by Gzulmie · Dec 29, 2016 at 10:05 PM
Solved it. The solution to this is to refer to the components via the animator, e.g. animator. GetComponent<"componentName">(); will refer to the component of that specific instance (game object).
If it helps anyone in the future.