Пример #1
0
    void Update()
    {
        Vector2 inputVector = new Vector2(Input.GetAxisRaw("Horizontal"), Input.GetAxisRaw("Vertical"));

        if (inputVector != Vector2.zero)
        {
            characterController.MoveTowardsPosition(transform.position + (Vector3)inputVector);
        }
    }
Пример #2
0
    void Update()
    {
        if (!goingToCarrot &&
            !returningHome &&
            carrotQuota > collectedCarrots)
        {
            targetCarrot = fieldManager.GetNearestFullGrownCarrot(transform.position);
            if (targetCarrot != null)
            {
                goingToCarrot          = true;
                spriteRenderer.enabled = true;

                if (!textHasBeenShown)
                {
                    textHasBeenShown = true; PopupManager.instance.ShowPopupEnemy(popupNumber);
                }
            }
        }

        if (goingToCarrot)
        {
            if (targetCarrot == null)
            {
                targetCarrot = fieldManager.GetNearestFullGrownCarrot(transform.position);
            }

            if (targetCarrot != null)
            {
                characterController.MoveTowardsPosition(targetCarrot.transform.position);
                if ((targetCarrot.transform.position - transform.position).magnitude < grabDistance)
                {
                    Destroy(targetCarrot.gameObject);
                    mouthCarrot.SetActive(true);
                    goingToCarrot = false;
                    StartCoroutine(ReturnCarrot());
                }
            }
        }
    }