Search Unity

  1. Unity 6 Preview is now available. To find out what's new, have a look at our Unity 6 Preview blog post.
    Dismiss Notice
  2. Unity is excited to announce that we will be collaborating with TheXPlace for a summer game jam from June 13 - June 19. Learn more.
    Dismiss Notice

Question why my script isn't working?

Discussion in 'Scripting' started by xuserx460, Apr 13, 2024.

  1. xuserx460

    xuserx460

    Joined:
    Apr 10, 2024
    Posts:
    3
    the script:
    Code (CSharp):
    1. using System.Collections;
    2. using System.Collections.Generic;
    3. using UnityEngine;
    4.  
    5. public class bird : MonoBehaviour
    6. {
    7.  
    8.     public Rigidbody myrigidbody;
    9.  
    10.     // Start is called before the first frame update
    11.     void Start()
    12.     {
    13.  
    14.     }
    15.  
    16.     // Update is called once per frame
    17.     void Update()
    18.     {
    19.  
    20.     }
    21. }
    22.  
    -expected behavior: a myrigidbody option
    https://imgur.com/a/hwUIsdG
    -the error : the assosiated script can not be loaded
    please fix any compile errors
    and assign a valid script
    -a screenshot of the error:
    https://imgur.com/a/iBP4qsb
     
  2. Ryiah

    Ryiah

    Joined:
    Oct 11, 2012
    Posts:
    21,479
    MonoBehaviour script class name has to match file name.
     
    xuserx460 and Kaesesnack like this.
  3. Kaesesnack

    Kaesesnack

    Joined:
    Apr 10, 2024
    Posts:
    40
    You were faster Ryiah :D
     
    xuserx460 likes this.
  4. xuserx460

    xuserx460

    Joined:
    Apr 10, 2024
    Posts:
    3
    thank you so much