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 the apple item (Method 2) - A Tutorial for Baldi's Basics


Script Stuff

1. Follow this tutorial made by T5mpler for adding an item

2. Go into the baldiscript add this into the update method

  if (this.EatingSoundDelay > 0f & this.AppleEating & this.startedEating)
        {
            this.EatingSoundDelay -= Time.deltaTime;
        }
        if (this.EatingSoundDelay <= 0f & this.AppleEating)
        {
            int num = Mathf.RoundToInt(UnityEngine.Random.Range(0f, 1f));
            this.baldiAudio2.PlayOneShot(this.BAL_Crunch[num]);
            this.times = Mathf.Round(UnityEngine.Random.Range(0f, 50f));
            if (this.times <= 2f)
            {
                this.baldiAudio2.PlayOneShot(this.BAL_Yum);
            }
            this.EatingSoundDelay = 0.05f; 

4. Add this in the move void


this.timeToMove = this.baldiWait - this.baldiTempAnger;
        this.AppleEating = false;
        this.startedEating = false;
        this.baldiAnimator.SetBool("EatingApple", false);
		this.previous = base.transform.position;

5. Add this somewhere in the script

public void Apple()
    {
        this.baldiAnimator.SetTrigger("Apple");
        this.timeToMove = (float)Mathf.RoundToInt((float)UnityEngine.Random.Range(13, 18));
        this.baldiAudio.PlayOneShot(this.BAL_Apple);
        this.AppleEating = true;
        this.EatingSoundDelay = 0.01f;
     }

7. Now add these: public bool AppleEating;    public bool startedEating;

public float times;

public float EatingSoundDelay;

public AudioSource baldiAudio2;

public AudioClip BAL_Apple;

    public AudioClip BAL_Yum;

public AudioClip[] BAL_Crunch = new AudioClip[2];

8. Now go into the player script and in the OnTriggerEnter function replace baldi with

  if (this.gc.item[0] != 13 && this.gc.item[1] != 13 && this.gc.item[2] != 13)
		{
            if (other.transform.name == "Baldi" & !this.gc.debugMode & !this.baldi.AppleEating)
            {
                this.gameOver = true;
            }
        }
        else if (other.transform.name == "Baldi" & !this.baldi.AppleEating)
        {
            this.Apple();
            this.AppleLose = false;
Replace the id with ur item id!

9.In the Ontriggerstay function put

if (this.gc.item[0] != 13 && this.gc.item[1] != 13 && this.gc.item[2] != 13)
		{
            if (other.transform.name == "Baldi" & !this.gc.debugMode & !this.baldi.AppleEating & !this.gameOver)
            {
                this.gameOver = true;
                RenderSettings.skybox = this.blackSky;
			    base.StartCoroutine(this.KeepTheHudOff());
            }
        }
        else if (other.transform.name == "Baldi" & !this.baldi.AppleEating)
        {
            this.Apple();
            this.AppleLose = false;

10. Add this somewhere

public void Apple()
    {
        this.baldi.Apple();
        if (this.gc.item[0] == 13 & !this.AppleLose)
        {
            this.gc.LoseItem(0);
            this.AppleLose = true;
        }
        else if (this.gc.item[1] == 13 & !this.AppleLose)
        {
            this.gc.LoseItem(1);
            this.AppleLose = true;
        }
        else if (this.gc.item[2] == 13 & !this.AppleLose)
        {
            this.gc.LoseItem(2);
            this.AppleLose = true;
        }
        else if (this.gc.item[3] == 13 & !this.AppleLose)
        {
            this.gc.LoseItem(3);
            this.AppleLose = true;
        }
        else if (this.gc.item[4] == 13 & !this.AppleLose)
        {
            this.gc.LoseItem(4);
            this.AppleLose = true;
		}
	}
Unity

11. Make your animation clips for his AppleIdle and his AppleEating

12. Now make a trigger called Apple and a Bool called EatingApple

13.Make a transition from the any state box give it the apple trigger then make a transition from that to the EatingApple clip give it the EatingApple bool make sure its true then a transition from that to the slap clip give it the same bool and change it to false

Done! Please credit Paulor94 for the code etc Thanks!
  • punkred avatar
    punkred Joined 3mo ago
    Offline
    545 points Ranked 50,716th
    22d
    Assets\Scripts\Assembly-CSharp\PlayerScript.cs(147,18): error CS1061: 'PlayerScript' does not contain a definition for 'AppleLose' and no accessible extension method 'AppleLose' accepting a first argument of type 'PlayerScript' could be found (are you missing a using directive or an assembly reference?)
    Hehe I made a nice mod :)
    URL to post:
  • punkred avatar
    punkred Joined 3mo ago
    Offline
    545 points Ranked 50,716th
    22d
    this all makez sense except for step 12 and 13, can i get a lil help with that plz?
    Hehe I made a nice mod :)
    URL to post:
  • Thanks for the tutorial! I think you just missed one on PlayerScript though :

    public bool AppleLose;
    Baldite avatar
    Mantra
    Baldite
    URL to post:
  • what update method?
    Bananite
    URL to post:
  • xTPSx avatar
    xTPSx Joined 2y ago
    TPS_Offline
    -19 points Ranked 89,233rd
    14 medals 1 legendary 1 rare
    • Returned 5000 times Medal icon
    • Returned 1000 times Medal icon
    • Returned 100 times Medal icon
    • Became a Studio Leader Medal icon
    • One month a member Medal icon
    • Reached 10 subscribers Medal icon
    2y 2y
    btw i forgot to add this put this in the update method aswell!!!!

      if (this.AppleEating & !this.baldiAudio.isPlaying)
            {
                this.startedEating = true;
                this.baldiAnimator.SetBool("EatingApple", true);            

    URL to post: