// Update is called once per frame void Update() { movement = Input.GetAxisRaw("Horizontal"); animator.SetFloat("Speed", Mathf.Abs(movement)); if (Input.GetButtonDown("Jump") && Mathf.Abs(rigidbody.velocity.y) < 0.001f) { jump = true; groundCheck = false; } if (Input.GetKeyDown(KeyCode.W)) { lookingUP = true; } if (Input.GetKeyUp(KeyCode.W)) { lookingUP = false; } if (Input.GetKeyDown(KeyCode.S)) { lookingDown = true; } if (Input.GetKeyUp(KeyCode.S)) { lookingDown = false; } if (Input.GetMouseButtonDown(0) || Input.GetKeyDown(KeyCode.P)) { if (WeaponType == false) { if (Time.time > nextShootTime) { attacking = true; if (m_FacingRight && lookingUP == false && lookingDown == false) { player.AttackWithCircle(attackDamage, Range, 1, 0); } else if (m_FacingRight == false && lookingUP == false && lookingDown == false) { player.AttackWithCircle(attackDamage, Range, -1, 0); } if (lookingDown) { player.AttackWithCircle(attackDamage, Range, 0, -1.5f); } if (lookingUP) { player.AttackWithCircle(attackDamage, Range, 0, 1.5f); } nextShootTime = Time.time + _attackSpeed; } } else { if (Time.time > nextShootTime) { attacking = true; if (m_FacingRight && lookingUP == false && lookingDown == false) { player.Attack(attackDamage, Range, 1, 0); } else if (m_FacingRight == false && lookingUP == false && lookingDown == false) { player.Attack(attackDamage, Range, -1, 0); } if (lookingDown) { player.Attack(attackDamage, Range, 0, -1); } if (lookingUP) { player.Attack(attackDamage, Range, 0, 1); } nextShootTime = Time.time + _attackSpeed; } } } if (Input.GetKeyDown(KeyCode.LeftShift)) { Running = 2f; } if (Input.GetKeyUp(KeyCode.LeftShift)) { Running = 1f; } /* * if (Input.GetKeyDown(KeyCode.F)) * { * myPlayer.health--; * } * if (Input.GetKeyDown(KeyCode.C)) * { * myPlayer.health++; * } * if (Input.GetKeyDown(KeyCode.R)) * { * myPlayer.numOfHearts++; * } * if (Input.GetKeyDown(KeyCode.Q)) * { * myPlayer.numOfHearts--; * } */ if (movement < 0) { m_FacingRight = false; transform.localRotation = Quaternion.Euler(0, 180, 0); } else if (movement > 0) { m_FacingRight = true; transform.localRotation = Quaternion.Euler(0, 0, 0); } }