I have this code attached to my player
var canJump : boolean;
var isJumping : boolean;
var onGround : boolean;
function FixedUpdate(){
if (onGround == false && isJumping == false){
transform.Translate(Vector3.down * Time.deltaTime);
}
}
function OnCollisionEnter2D(collision : Collision2D){
if (collision.gameObject.tag == "Ground"){
onGround = true;
Debug.Log("Hit solid ground");
}
}
But the onGround variable isn’t changing to true, i’m passing through the object tagged “ground” and “Hit solid ground” isn’t getting logged. I tried attaching a 2D rigidbody to the player and whislt it did stop when it hit the ground, the onGround variable stayed as false. Both the ground and the player have a 2D Box Collider attached. what’s going on?