Hi!
I’m new to coding in Unity and can’t seem to figure out whats wrong. When I try to compile I get the following error.
“error CS1061: Type ‘UnityEngine.Collision2D’ does not contain a definition for ‘gameobject’ and no extension method 'gameobject of type ‘UnityEngine.Collision2D’ could be found. Are you missing an assembly reference?”
Unity, Visual Studio 2017 and the VSTU are fully updated. This is what currently won’t compile. As far as I can tell I haven’t seen a solution to this problem, nor anyone else asking about this so I assume its a small thing I have overlooked.
Any help would be appreciated.
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class DestroyTransform : MonoBehaviour
{
// Use this for initialization
void Start()
{
}
// Update is called once per frame
void Update()
{
}
protected void OnCollisionEnter2D(Collision2D coll)
{
if (coll.gameObject.tag == "Collision")
{
Destroy(coll.gameobject);
}
}
}