Ads keep us online. Without them, we wouldn't exist. We don't have paywalls or sell mods - we never will. But every month we have large bills and running ads is our only way to cover them. Please consider unblocking us. Thank you from GameBanana <3

How To Add An Item That Can Stun Characters

A Tutorial for Baldi's Basics in Education and Learning

Members see zero ads. Membership is 100% free
Hello! In this tutorial i will show you how to add an item to baldi's basics using the open source decompile that can stun characters for an amount of time of your choosing. (Follow what i do closely, or else it might not work)

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
            {
                RaycastHit raycastHit;
                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)
                {
                    StartCoroutine(StunItem(raycastHit.transform.gameObject));
                    this.ResetItem();
                }
                return;
            }


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!

Comments

Sign up to access this!

Embed

menu
Compartir banner
URL de la Imágen
Incrustar código HTML
Código BB incrustado
Markdown embed code

Credits

Original Authors
JohnsterSpaceProgram Johnster Space Studio Flag
Affiliation
Johnster Space Studio
Offline
6,195 points Ranked 1042nd
20 medals 2 rare
  • Returned 1000 times Medal icon
  • 10 submissions featured Medal icon
  • Returned 100 times Medal icon
  • One month a member Medal icon
  • Submitted 5 Gamefiles Medal icon
  • 6 months a member Medal icon
Created This Tutorial
Special Thanks
MissingTextureMan101 avatar Ruler Productions Flag
Affiliation
Ruler Productions
MissingTextureMan101 username pic Joined 1y ago
Offline
Ruler Productions Flag Affiliation: Ruler Productions
1,861 points Ranked 20975th
18 medals 4 rare
  • 10 submissions featured Medal icon
  • Returned 1000 times Medal icon
  • Received thanks 50 times Medal icon
  • Reached 50 subscribers Medal icon
  • One month a member Medal icon
  • Became a Studio Leader Medal icon
The OSB Project Decompile
Fasguy avatar 30Hz Studios Flag
Affiliation
30Hz Studios
Fasguy username pic Joined 1y ago
Offline
30Hz Studios Flag Affiliation: 30Hz Studios
2,314 points Ranked 20306th
12 medals 2 rare
  • Reached 50 subscribers Medal icon
  • Returned 1000 times Medal icon
  • Returned 100 times Medal icon
  • One month a member Medal icon
  • Reached 10 subscribers Medal icon
  • 6 months a member Medal icon
Showing me how to do this originally
ThisMarioFan
ThisMarioFan Joined 3mo ago
Offline
How to add new items tutorial

Submitter

JohnsterSpaceProgram avatar
Prob. At School
6,195 points Ranked 1042nd
20 medals 2 rare
  • Returned 1000 times Medal icon
  • 10 submissions featured Medal icon
  • Returned 100 times Medal icon
  • One month a member Medal icon
  • Submitted 5 Gamefiles Medal icon
  • 6 months a member Medal icon
JohnsterSpaceProgram Johnster Space Studio Flag
Affiliation
Johnster Space Studio

Creator
  • Paypal Donate
Sign up to access this!
Sign up to access this!
Sign up to access this!

Game

Sign up to access this!

Category

Details

Difficulty Level
Advanced

Attributes

Share

  • Share on Reddit
  • Share on Twitter
  • Share on Facebook
  • favorite 3
  • remove_red_eye 884
  • mode_comment 4
  • access_time 2mo
  • access_time 2mo

More from Submitter

menu

WiPs by Submitter

menu

More Decompile Tutorials