private void FixedUpdate()
    {
        if (!stomachMenuActive)
        {
            if (!eating)
            {
                mover.Walk(horizontalInput * walkForce);
            }

            if (jump && grounded && !eating)
            {
                mover.Jump(jumpForce);
                jump = false;
            }

            if (eatingInput && infrontFood)
            {
                eating = true;
                actionButton.SetActive(false);
                progressBar.gameObject.SetActive(true);
                progressBar.value = currentFood.GetCurrentProgress();
                if (currentFood.EatMe(eatingRate * Time.deltaTime))
                {
                    Instantiate(currentFood.stomachObject, stomachSpawnPoint.transform);
                    Destroy(currentFood.gameObject);
                    Debug.Log("fertig gegessen");
                }
            }
            else
            {
                if (progressBar.gameObject.activeSelf)
                {
                    progressBar.gameObject.SetActive(false);
                }
                eating = false;
            }

            if (stopEatingInput && currentFood != null)
            {
                currentFood.StopEating();
            }

            if (infrontFood)
            {
                if (!actionButton.activeSelf && !eating)
                {
                    actionButton.SetActive(true);
                }
            }
        }
        else if (stomachMenuActive)
        {
        }

        if (Mathf.Abs(horizontalInput) < 0.1f)
        {
            rb.velocity = new Vector2(Mathf.Lerp(rb.velocity.x, 0, walkDrag * Time.deltaTime), rb.velocity.y);
        }
        rb.velocity = new Vector2(Mathf.Clamp(rb.velocity.x, -maxSpeed, maxSpeed), rb.velocity.y);
    }
Ejemplo n.º 2
0
    void OnTriggerEnter(Collider other)
    {
        CharacterMover mover = other.gameObject.GetComponent <CharacterMover>();

        if (mover != null)
        {
            mover.Jump();
        }
    }
Ejemplo n.º 3
0
    void Update()
    {
        var x = Input.GetAxis("Horizontal");
        var y = Input.GetAxis("Vertical");

        mover.MovementDirection = new Vector3(x, 0, y);

        if (Input.GetKeyDown(KeyCode.Space))
        {
            mover.Jump();
        }
    }