The following tutorial will teach you how to add a head indicator for opening a door, like in Baldi's Basics Kickstarter Exlusive Demo and Baldi's Basic Random Maps Series.
1. Getting Started and UI StuffStart by importing all of the textures you need to make the head indicator, preferably the shaking, noticed, and confused sprites. After you imported them and made them transparent by checking "Alpha is Transparency" in the settings of the textures. Create a new Raw Image in the Hud. Apply an Animator to the said raw image. After you did that, create a new AnimatorController. Let's call this "HeadAnimator". Assign it in the "Runtime Animator Controller" slot in your image, and open the Animator window to start animating.
2. AnimationOnce you're in the animator window, create three new animation clips. Calling these "HeadIdle", "Notice", and "Confused" are recommended. You'll have to experiment with this next step, but you want to edit the Animation Clips until you're happy with them. Make sure at the end of the "Notice" and "Confused" animations, the Baldi Head disappears or goes off-screen (to do this, click on "Add Property",open the "Transform" menu, and click on the plus arrow next to "Position", and you can animate it sliding off-screen like that.) After you're happy with your clips. Import them into the animator by simply dragging them in. WARNING: The order in which you drag them in is important. You must start by importing the "HeadIdle" animation first. Otherwise, the noticing and confused animations will play once you start the game. Afterwards, make 2 transitions going from the "Any State" box to each of the other animation clips. Make 2 triggers, and called them "notice" and "confused". When you click on the white arrows in the Animator window, you'll see a box with a warning above it. Click the plus sign on the bottom right of the box to add a trigger, and choose the corresponding trigger ("notice" for the noticing animation, and "confused" for the confused animation.) When you're done, your animator window should look like this:
3. CodingThe coding portion is actually really simple, and does not require any complex stuff like IEnumerators. All you have to do for the coding portion is go to BaldiScript and add the variable
"public Animator head" at the bottom. Then, in the "Hear" method, replace the code with:
if (!this.antiHearing && priority >= this.currentPriority)
this.currentPriority = priority;
Make sure to assign the Animator of the head in BaldiScript. to do this, left-click on Baldi, find where it says "None (Animator)", drag the Raw Image into the said slot, and it will assign it.