예제 #1
0
    private void _computeCollisions(ref Vector3 velocity)
    {
        Collision = Directions.None;

        Distances.Reset();
        SlopeAngles.Reset();
        Info.Reset(velocity);

        Bounds _bounds = _collider.bounds;

        _bounds.Expand(-SkinWidth * 2);
        _boundingPoints.TopRight    = new Vector3(_bounds.max.x, _bounds.max.y, 0.0f);
        _boundingPoints.TopLeft     = new Vector3(_bounds.min.x, _bounds.max.y, 0.0f);
        _boundingPoints.BottomRight = new Vector3(_bounds.max.x, _bounds.min.y, 0.0f);
        _boundingPoints.BottomLeft  = new Vector3(_bounds.min.x, _bounds.min.y, 0.0f);

        _computeDescendingSlope(ref velocity);
        _computeHorizontalCollisions(ref velocity);
        _computeVerticalCollisions(ref velocity);

        Debug.DrawRay(transform.position, velocity, Color.white);
        transform.Translate(velocity);
    }