I’m begginer and I’m using an old tutorial from 2014 but due to Unity API changes I have encountered many issues with scripts, unfortunately I’m unable to figure this one out. Could anyone help? I already tried like 100 times using different methods but I end up with more and more errors…
using UnityEngine;
using System.Collections;
public class DestroyOther : MonoBehaviour{
void OnTriggerEnter2D(Collider2D other) {
Destroy(other.gameobject);
}
}
‘Collider2D’ does not contain a definition for ‘gameobject’ and no extenstion method ‘gameobject’ accepting a first argument of type ‘Collider2D’ could be found (are you missing a using directive or an assembly reference?)
and yes Objects that use script Collider2D attached have “IsTrigger” checked.
And also, after correcting the typo I receive another 3 errors.
The best overloaded method match for ‘UnityEngine.Object.Destroy(UnityEngine.object’ has some invalid arguments
Argument ‘#1’ cannot convert ‘object’ expression to type ‘UnityEngine.Object’
Type UnityEngine.Collider2D' does not contain a definition for gameobject’ and no extension method gameobject' of type UnityEngine.Collider2D’ could be found (are you missing a using directive or an assembly reference?)