Search Unity

Question Why is 'error CS1022: Type or namespace definition, or end' coming?

Discussion in 'Code Editors & IDEs' started by Ritvik_Nellutla, Jul 24, 2022.

  1. Ritvik_Nellutla

    Ritvik_Nellutla

    Joined:
    Jul 14, 2022
    Posts:
    17
    Hello, this is my first project in Unity that I hope to make successfully. I keep coming into an error, and I am not able to figure out what the problem is. I am listing the error and code below.

    Error -
    Assets\Scripts\Collectables\CollectCoin.cs(13,5): error CS1022: Type or namespace definition, or end-of-file expected

    Code -
    using System.Collections;
    using System.Collections.Generic;
    using UnityEngine;

    public class CollectCoin : MonoBehaviour
    {
    public AudioSource coinFX;

    void OnTriggerEnter(Collider other);
    }
    coinFX.Play();
    this.gameObject.SetActive(false);
    }
    {


    Please see if you can help,
    Thank you so much
     
  2. CodeSmile

    CodeSmile

    Joined:
    Apr 10, 2014
    Posts:
    5,888
    check the braces
     
  3. Ritvik_Nellutla

    Ritvik_Nellutla

    Joined:
    Jul 14, 2022
    Posts:
    17
    Okay, thank you! Can you please tell me which specific braces I need to change?
     
  4. Ritvik_Nellutla

    Ritvik_Nellutla

    Joined:
    Jul 14, 2022
    Posts:
    17
    Hello,
    I am very new to Unity and this is my first project I am trying to make. I keep getting this error, and I am not understanding why that is so. Here is the error is says, and below is my code.


    ERROR - Assets\Scripts\Collectables\RotateObject.cs(5,14): error CS0101: The namespace '<global namespace>' already contains a definition for 'RotateObject

    CODE -
    using System.Collections;
    using System.Collections.Generic;
    using UnityEngine;

    public class RotateObject : MonoBehaviour
    {
    public int rotateSpeed = 1;

    void Update()
    {
    transform.Rotate(0, rotateSpeed, 0, Space.World);
    }
    }




    Please see if you can help,
    Thank you!