protected override void OnCollision(Collider2D collider, Vector2 contactPosition) { GameObject collidedObject = collider.gameObject; string layerName = LayerMask.LayerToName(collidedObject.layer); string tagName = collidedObject.tag; if (ceilingCollision) { if (jumpVarTimer < jumpVarTime - jumpVarCeilingGrace) { jumpVarTimer = 0; } } if (grounded) { if (tagName == "Platform") { PlatformObject platformScript = collidedObject.GetComponent <PlatformObject>(); if (!platformScript.movingPlatform) { OnLanded(); } if (platformScript.disappearingPlatform) { platformScript.BeginDisappear(); } } else { cameraController.SetVerticalState(CameraController.VerticalState.PositionLock); lastLandedPlatformHeight = float.NegativeInfinity; } animator.SetBool("Jumping", false); } else if (layerName == "Enemy") { OnHit(collider, contactPosition); } else if (layerName == "Trap") { OnDeath(); } }