I don’t understand why this isn’t working:
if (Physics.Raycast (CrosshairRay, out hit, PickUpDistance)) {
Destroy(hit.collider.GameObject);
}
what i want to do is get the gameobject the ray hits and destroy it i know its something to do with the “Destroy()” line, but why is this not working its giving me errors:
1: error CS1061: Type UnityEngine.Collider' does not contain a definition for GameObject’ and no extension method GameObject' of type UnityEngine.Collider’ could be found (are you missing a using directive or an assembly reference?)
2: error CS1502: The best overloaded method match for `UnityEngine.Object.Destroy(UnityEngine.Object)’ has some invalid arguments
3: error CS1503: Argument #1' cannot convert object’ expression to type `UnityEngine.Object’