Hi,
What would be a reason why I get the error:
MissingComponentException: There is no
‘Animator’ attached to the “Character”
game object, but a script is trying to
access it.
… Even though there IS an active animator attached to it?
The problem concerns a line inside of a prefab.
I use
GameObject.Find(“Character”).transform.gameObject.GetComponent().SetTrigger(“StopCharacter”);
The GameObject.Find("Character").transform.gameObject returns the correct gameObject, but for some reason, its Animator cannot be accessed.
EDIT: the target object is not a prefab, but the script that tries to access it is attached to a prefab.
Hi there, thanks for your response. Unfortunately it didn't solve it. Maybe it's a known bug in Unity...
– ez06@alex55555 I highly doubt that it’s a bug in Unity. You say that it’s prefab, then how can you find prefab, check that the game object is in sync with the prefab. If still doesn’t work, try making public variable of type Animator, and manually attach it in the inspector. @Griffo you added an extra “.” in the
– lordlycastleGetComponentHi. Actually the target object is not a prefab, but the script that tries to access it is attached to a prefab. Since the target object is not a prefab, it should be accessible with no error.
– ez06is the prefab in the scene at the start or do you instantiate it into the scene?
– Griffo@lordlycastle The exta "." in the GetComponent is Javascript
– Griffo