Here’s my code:
void OnTriggerExit2D(Collider2D other){
grounded = false;
gen = false;
if (other.gameObject.GetInstanceID!=lastcollidedobject) {
if (other.tag == "MovingPlatform") {
}
if (other.tag == "Hills" || other.tag == "MovingPlatform" && other.transform.position.y - transform.position.y < -3) {
//
score++;
groundcheck = 0;
if (other.tag == "Hills") {
lastcollidedobject = other.gameObject.GetInstanceID ();
//Destroy (other.gameObject);
}
}
}
}