- Home /
How can I call functions in multiple scripts, if they have the same name?
I'm trying to code my dialogue system in Unity.
I have one script called DialogueManager, which works with the UI, sound, scrolling through text, and ending the dialogue when it is complete. The DialogueManager is attached to an empty game object.
Then, I have a DialogueTrigger scripts on each of my NPCs that can be talked to. It handles the collider which allows you to talk to the NPC, the inputs, and the animations for that NPC.
The issue is, my DialogueManager needs to communicate with DialogueTrigger to trigger a function which ends animations, but "FindObjectOfType()" only calls the script to end the talking animation on one of my NPCs, so the others never finish their animations.
Answer by elijahjmickelson · May 19, 2021 at 12:29 AM
Figured it out:
DialogueTrigger[] DialogueTriggerList = GetComponentsInChildren<DialogueTrigger>();
foreach (DialogueTrigger tg in DialogueTriggerList)
{
tg.StopTalkingAnimation();
}
Your answer
Follow this Question
Related Questions
Point Counter Works Only Once! 1 Answer
How to double spirte/gameobject/prefab and control the result on those items? 0 Answers
How would I access my list from another function? 1 Answer
Shooting with get joint rotation .eulerAngles kinect 0 Answers
How to make a companion that trails character moves, and not collide? 0 Answers