An Object Reference is required to access non-static member 'UnityEngine.Collision.collider'

I’ve looked this up online but I can’t really figure out how the solutions other people are using work, so I’m asking for a more “specific to my situation” solution. My code:

using UnityEngine;
using System.Collections;

public class PlayerHealth : MonoBehaviour {

    	int playerHealth = 100;
    	// Use this for initialization
    	void Start () {
    	// Update is called once per frame
    	void Update () {
    		if (Collision.collider.tag == "Enemy") 
    			playerHealth = playerHealth - 10;
    		if (playerHealth <= 0){
    			Destroy (gameObject);

I get the error at (15, 31). Any help would be nice, and I am quite new to C#, so noob friendly if possible?

Collision is a type of object, not an object itself. In other words, it’s a blueprint for an object, not an object built with the blueprint.


House home = new House();

House is the blueprint, home is the building you built with it. It makes sense to look for your bed inside your home.

Bed bed = home.bed;

It doesn’t make sense to look for a bed in a blueprint.

Bed bed = House.bed;

The error you have is telling you that ‘Collision’ in the code Collision.collider is not an object, but rather a blueprint for an object, so you can’t look for things in it.

A bit more to it than that, but hopefully that gets the point across.