Step 1. Open The Open Source Baldi Decompile In Unity
Step 2. Import a 64px by 64px image you would like to use for the item (For this tutorial's purpose, the image I chose is pretty generic)
Step 3. Duplicate one of the existing items (like Pickup_BSODA for example)
Step 4. Rename the duplicate to Pickup_StunItemName (I renamed it to Pickup_StunGun)
Step 5. Give the stun item the texture you chose for it
Step 6. Open the PickupScript in Visual Studio
Step 7. In the script, duplicate the Pickup_SafetyScissors code and paste the copied code below it. Change the string to the item name you changed earlier, and the number to 10.
Step 8. Go back to Unity. Select the game controller object and scroll down until you get to item textures. Change the size to 11, and after doing that, replace the duplicate scissor texture with the texture of your stun item in element 10.
Step 9. Now open the gamecontroller script with visual studio, and I will show you what exactly you need to do (This is probably the hardest part)
Step 10. Scroll down to the ResetItem code, and under that, between ResetItem() and LoseItem(), paste in this code:
IEnumerator StunItem(GameObject character)
float timer = 5f;
UnityEngine.AI.NavMeshAgent navMeshAgent = character.GetComponent
while (timer > 0)
navMeshAgent.velocity = Vector3.zero;
timer -= Time.deltaTime;
yield return new WaitForEndOfFrame();
Now, after you put in the code, you are going to notice some errors (Don't worry, I will show you how to fix that)
Step 11. Hover over IEnumator in the code you pasted, and click on the arrow. using System.Collections; should come up as a fix, click on that. The errors for the IEnumator should go away. (You can change how long the stun lasts for by changing the float timer's number)
Step 12. Now we need to put in the code for the stun item itself. Under the else if for the safety scissors code, copy and paste this code in:
else if (this.item[this.itemSelected] == 10) // Stun Item Code
if (Physics.Raycast(Camera.main.ScreenPointToRay(new Vector3((float)(Screen.width / 2), (float)(Screen.height / 2), 0f)), out raycastHit) && raycastHit.collider.tag == "NPC" && raycastHit.collider.name != "Baldi" && Vector3.Distance(this.playerTransform.position, raycastHit.transform.position) <= 10f)
Now with all the code for the item in, we are almost done! All we need to do now is give the item its in-game name.
Step 13. Go down to where it shows the names of all the items. Under safety scissors, put the name of your item in "" marks. (After doing that save the script and go back into unity)
Now when you play your decompile in unity, the stun item should work! To make sure, test it on some characters like playtime or the principal. If they stop moving after you use it on them for a few seconds, that means it worked!
I hope you enjoyed this tutorial, and that it helped you with making a new item!