S
S
strelok_10142021-01-22 00:41:26
Unity
strelok_1014, 2021-01-22 00:41:26

Error CS0101: The namespace '' already contains a definition for 'Destroyable'?

Guys, please help. It would seem that I have only 27 lines of code, but it’s not clear where the 3 errors come from ... It seems that I wrote everything correctly.
1 Error CS0101: The namespace '' already contains a definition for 'Destroyable'
2 Error CS0111: Type 'Destroyable' already defines a member called 'Start' with the same parameter types
3 Error CS0111: Type 'Destroyable' already defines a member called 'Update' with the same parameter types

My code

using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class Destroyable : MonoBehaviour
{
    // Start is called before the first frame update
    void Start()
    {
        
    }

    // Update is called once per frame
    void Update()
    {
        
    }

    private void OnCollisionEnter2D(Collision2D collision)
    {
        if (collision.gameObject.tag == "Player")
        {
            collision.gameObject.GetComponent<Rigidbody2D>().AddForce(transform.up * 8f, ForceMode2D.Impulse);
            gameObject.GetComponentInParent<Enemy>().startDeath();
        }
    }
}

Answer the question

In order to leave comments, you need to log in

1 answer(s)
F
freeExec, 2021-01-22
@freeExec

Two identical files in a project

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question