void Move(float h, float v)
    {
        movement.Set(h, 0f, v);
        movement = movement.normalized * speed * Time.deltaTime;
        Vector3 temp = transform.position + movement;

        if (Mathf.Sqrt(Mathf.Pow(temp.x, 2F) + Mathf.Pow(temp.z, 2F)) > 20)
        {
            playerAg.updateReward(-0.01f);
            temp = transform.position;
        }
        playerRigidbody.MovePosition(temp);
    }
Esempio n. 2
0
    public void TakeDamage(int amount)
    {
        //print("TakeDamage");
        playerAg.updateReward(-0.1f);
        damaged = true;

        currentHealth -= amount;

        healthSlider.value = currentHealth;

        playerAudio.Play();

        if (currentHealth <= 0 && !isDead)
        {
            Death();
        }
    }