예제 #1
0
    // FIXED UPDATE
    private void FixedUpdate()
    {
        if (rb.velocity.y < 0f)
        {
            RaycastHit2D blHit = Physics2D.Raycast(bounds.getBottomLeftWorldPoint(), -Vector2.up, raycastLength);
            RaycastHit2D brHit = Physics2D.Raycast(bounds.getBottomRightWorldPoint(), -Vector2.up, raycastLength);

            if (blHit.collider != null || brHit.collider != null)
            {
                // collision below has occurred
                gravity.doDisableGravity();
                transform.position = new Vector2(0f, blHit.point.y + bounds.getDefaultBoundsObject().extents.y - boundsOffset.y);
            }
        }
    }