[help] Collision script issue

I am a beginner at unity and i am stuck on making a script that simply changes the scene when a player touches the cube
[Issues= Assets/Scripts/Collision.cs(4,0): error CS1525: Unexpected symbol public', expecting .’ or ; Assets/Scripts/Collision.cs(4,14): error CS0101: The namespace global::’ already contains a definition for Collision' Assets/Scripts/Collision.cs(7,8): error CS1519: Unexpected symbol void’ in class, struct, or interface member declaration]

using UnityEngine;
using System.Collections;
using UnityEngine.SceneManagement;

public class Collision : MonoBehaviour
{
    void OnTriggerEnter(Collider other)
    {
        if(other.CompareTag("Player"))
        {
        SceneManager.LoadScene(1);
        }
    }
}

Your “Collision” class conflicts with UnityEngine.Collision class. Two solutions: a) Place your class under a namespace. b) Rename your class. The last solution is better, because your class is not very well named. If the purpose of the script is to load a scene on trigger enter, name it for example “OnTriggerEnterLoadScene”. Also consider promoting both the level index (or name) and the tag as public variables so that you can change them in the Inspector and reuse your code :slight_smile:

1 Like

Thanks for your help!