error CS1061: 'Collider2D' does not contain a definition for 'GameObject'

Getting The Error
error: cs(30,32)CS1061: ‘Collider2D’ does not contain a definition for ‘GameObject’ and no accessible extension method ‘GameObject’ accepting a first argument of type ‘Collider2D’ could be found (are you missing a using directive or an assembly reference?)
I need help, I just don’t get why I’m getting this error. Here is the code, it is a script for my sword hitbox to damage the enemy.

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

public class HurtEnemy : MonoBehaviour
{

    public int damageToGive = 1;


    // Start is called before the first frame update
    void Start()
    {

    }

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

    }


    private void OnTriggerEnter2D(Collider2D other)
    {

        if (other.tag == "Enemy")
        {
            HealthManager eHealthMan;
            eHealthMan = other.GameObject.GetComponent<HealthManager>();
            eHealthMan.HurtEnemy(damageToGive);


        }

    }
}

lol “other.GameObject.GetComponent” should’ve been “other.gameObject.GetComponent” with a lowercase g

4 Likes

ist das richtig

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

public class NextLevel : MonoBehaviour {

void OnTriggerEnter2D(Collider2D other)
{
if (other.Tag == “Spieler”) {
Debug.Log (“Nächstes Level”);
SceneManager.LoadScene(SceneManager.GetActiveScene().buildIndex +1);
}
}
}

weil bei mir ist immer ein fehler

So much thanks bro

Thanks is always appreciated but please use the like button rather than necroing a thread.

Thanks.