void FixedUpdate() { if (Input.GetButtonDown("Restart")) { SceneManager.LoadScene(0); } if (!isDead) { // Rotate character if (Input.GetAxis("Mouse X") != 0 || Input.GetAxis("Mouse Y") != 0) { var objectPos = Camera.main.WorldToScreenPoint(transform.position); var targetX = Input.mousePosition.x - objectPos.x; var targetY = Input.mousePosition.y - objectPos.y; var angle = Mathf.Atan2(targetY, targetX) * Mathf.Rad2Deg - 90f; rigidBody2d.MoveRotation(angle + turnSpeed * Time.fixedDeltaTime); } // Shoot if (Input.GetAxis("Fire1") != 0) { Shoot(); } // Move or Dash var moveDirection = new Vector2(Input.GetAxisRaw("Horizontal"), Input.GetAxisRaw("Vertical")); moveDirection.Normalize(); if (Input.GetKeyDown(KeyCode.Space) && !isDashing && Time.time > nextDash) { moveSpeed += dashSpeed; Invoke("DashComplete", dashDuration); isDashing = true; nextDash = Time.time + dashCooldown; gameControllerScript.Dash(dashCooldown); } rigidBody2d.MovePosition(rigidBody2d.position + moveDirection * moveSpeed * Time.fixedDeltaTime); // Reload if (Input.GetButtonDown("Reload") && !isReloading && ammoStored > 0) { isReloading = true; gameControllerScript.Reload(reloadDuration); reloadSound.Play(); Invoke("Reload", reloadDuration); } } }