Esempio n. 1
0
    internal RaycastHit2D GetBelowHit(float rayLength, Vector2 deltaMove = default)
    {
        Transform    rayOriginTransform = physics.goAround ? rotateRayOrigin : goBackRayOrigin;
        Vector2      rayOrigin          = (Vector2)rayOriginTransform.transform.position + deltaMove;
        Vector2      rayVector          = rotation.GetDownVector();
        RaycastHit2D hit = CastRay(rayOrigin, rayVector, rayLength, bottomRayLayerMask);

        return(hit);
    }
Esempio n. 2
0
    private void RotateSnail90()
    {
        Quaternion rotationQuaternion = Quaternion.AngleAxis(-90, transform.forward);
        Vector2    rotatedDownVector  = rotationQuaternion * rotation.GetDownVector();
        Vector2    rotatedFrontVector = rotationQuaternion * rotation.GetFrontVector();

        rotation.Rotate90();
        movement.raycaster.InvalidateBounds();

        Vector2 rotatedDownMoveAmount   = movement.TryToMove(rotatedDownVector * groundCheckDistance);
        Vector2 rotateForwardMoveAmount = movement.TryToMove(rotatedFrontVector * forwardMoveAfterRotation);

        if (rotationFrames > 0)
        {
            hasRbRotated = true;
            float t = 1 - (float)rotationFramesLeft / rotationFrames;
            spriteRenderer.transform.localRotation = Quaternion.Lerp(counterClockwise90Rotation, noRotation, t);
        }
    }