Okay guys, so I am learning C# as I go so I apologize for any stupid questions.
What I am trying to do right now is have an object (as well as the LinkedSpriteManager sprite drawn over it) be destroyed whenever it collides with any of four boundary cubes. I don’t even need a specific object to be destroyed, just anything that comes in contact with the walls.
I have tried using ControllerColliderHit.gameObject as so:
using UnityEngine;
using System.Collections;
public class Walls : MonoBehaviour
{
void OnCollisionEnter() {
Destroy(ControllerColliderHit.gameObject);
}
}
(attached to the walls that I want to destroy anything that collides with them)
but I receive “UnityEngine.ControllerColliderHit.gameObject: An object reference is required for the nonstatic field, method or property”.
This is the same error that is generated when I try to use any Collider functions such as Collision.gameObject.
Does anyone have any insight? Perhaps another way to do things? I feel I am missing something terribly obvious.