private void OnCollisionExit2D(Collision2D collision) { KNGPlatform platform = collision.gameObject.GetComponent <KNGPlatform>(); if (platform != null) { grounded = false; } }
private void OnCollisionEnter2D(Collision2D collision) { GameObject other = collision.collider.gameObject; if (other.GetComponent <KNGKillZone>() != null) { // we hit a kill zone, destroy this object GameObject.Destroy(gameObject); } else { KNGPlatform platform = other.GetComponent <KNGPlatform>(); if (platform != null) { grounded = true; if (platform.isObstacleFlipper) { // we hit a platform, flip momentum ChangeDirection(); } } } }