Reputation: 254
I'm new on Unity2D.Although I set my ground tag to 'GROUND', if condition does not work..
void onCollisionEnter2D(Collision2D other){
if (other.gameObject.tag == "GROUND"){
isGrounded = true;
Jumping = false;
anim.SetInteger("Status", 0);
}
}
Upvotes: 0
Views: 1489
Reputation: 441
Try using CompareTag() to check the tag of the gameObject.
void onCollisionEnter2D(Collision2D other){
if (other.gameObject.CompareTag("GROUND")){
isGrounded = true;
Jumping = false;
anim.SetInteger("Status", 0);
}
}
Upvotes: 1
Reputation: 125245
The function is not even being called. It is OnCollisionEnter2D
not onCollisionEnter2D
. Fix that and your problem should be solved.
Not related to your problem, but it is more efficient to use the CompareTag
function to compare tags. So your if (other.gameObject.tag == "GROUND")
should be if (other.gameObject.CompareTag("GROUND"))
Upvotes: 3