// Update is called once per frame
    void Update()
    {
        if (health != int.Parse(healthText.text.ToString().Split('/')[0]))
        {
            UpdateText();
        }
        if (health <= 0)
        {
            ObjectPool.Spawn(deathEffect, transform.position, Quaternion.identity);
            playerSpawn.RespawnPlayer();
        }

        isGrounded = Physics2D.OverlapCircle(groundCheck.position, checkRadius, whatIsGround);

        if (moveInput > 0)
        {
            transform.eulerAngles = new Vector3(0, 0, 0);
            anim.SetBool("isRunning", true);
        }
        else if (moveInput < 0)
        {
            transform.eulerAngles = new Vector3(0, 180, 0);
            anim.SetBool("isRunning", true);
        }
        else
        {
            anim.SetBool("isRunning", false);
        }

        if (isGrounded == true && Input.GetKeyDown(KeyCode.Space))
        {
            isJumping = true;
            anim.SetTrigger("Jump");
            jumpTimeCounter = jumpTime;
            rb.velocity     = Vector2.up * jumpForce;
        }

        if (Input.GetKey(KeyCode.Space) && isJumping == true)
        {
            if (jumpTimeCounter > 0)
            {
                rb.velocity      = Vector2.up * jumpForce;
                jumpTimeCounter -= Time.deltaTime;
            }
            else
            {
                isJumping = false;
            }
        }
        if (Input.GetKeyUp(KeyCode.Space))
        {
            isJumping = false;
        }
        if (Input.GetKeyDown(KeyCode.LeftShift) && isGrounded)
        {
            useDashAbility();
        }
    }
Beispiel #2
0
 private void Update()
 {
     if (health != int.Parse(healthText.text.ToString().Split('/')[0]))
     {
         UpdateText();
     }
     if (health <= 0)
     {
         ObjectPool.Spawn(deathEffect, transform.position, Quaternion.identity);
         playerSpawn.RespawnPlayer();
     }
 }