Problem with activating an animation via my script, help please!

Hello, I’m entirely new to coding and am starting a coding course next year - so I wanted to jump right in and learn some stuff about c# before I started.

To do this I’m using Unity. Basically, in my main menu, I want my camera to pan up when the space button is pressed (it’s a main menu animation). Here’s my code:

using UnityEngine;
using System.Collections;

public class Mainmenustart : MonoBehaviour {

   
        public bool animation_bool;
       
        void Update()
        {
           
            if(animation_bool == true)
            {
                Animation.Play("Main_Menu_Pan");
               
            }
           
           
            if(Input.GetButtonDown("space"))
            {
                animation_bool = true;
               
            }
           
           
           
        }
    }
}

The problem arises when I try to play my game - it says there is a compile error? If you guys could point out the error in easy-to-understand terms that’d be great! I’m doing beginner tutorials for C# too, but they obviously don’t apply to well in the context of executing animations like this.

Thanks!

look at the console, it’ll tell you what the compilation error is, what script it is in and what line it is on.

without knowing that… I’m guessing line 14 is the cause, you’re trying to access the class when you really should be trying to access the local instance… although you also don’t have a local instance, so you’ll need to either use a “GetComponent” function to get the local animation instance on the gameobject or have a public variable in the class and specify it in the inspector.