# Collision2d Unity To Change Another Scripts Int Value

I am looking to decrease the value stored in my script "progress" which takes 1 away from a value curHealth, when the Player sprite to which this script "collision", is attacked/ touching the Enemy 2d box collider. The decreasing of the value doesn't happen when the two objects touch. Both the Player and the Enemy have 2dbox colliders and other shape 2d colliders.

using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class collision : MonoBehaviour {

public progress Progress = GameObject.FindGameObjectWithTag("HealthBar").GetComponent<progress>();

void OnCollisionStay2d(Collision2D coll){
if (coll.gameObject.name == "Enemy") {

Progress.curHealth -= 1;

}
}

}

• can you see on the editor that "public progress Progress" is assigned correctly? – Thalthanas Jul 14 '17 at 7:12
• Yes it was, just as @Tolga Sen pointed out, I capitalized the object and not the class. – Mike noah Jul 14 '17 at 20:29

Your OnCollisionStay2D function has a typo. Capitalize the letter "d" at the end, then it will work if there is not another problem. And also another tip, please do capitalize the first letter of Classes, not the objects.