void FixedUpdate() { string joyRestart = (PS4Controller) ? ("PS4 Restart") : ("Joy Restart"); if (Input.GetButtonDown(joyRestart)) { SceneManager.LoadScene(0); } if (!isDead) { // Rotate character string joyRightHoriz = (PS4Controller) ? ("PS4 Right Horizontal") : ("Joy Right Horizontal"); string joyRightVert = (PS4Controller) ? ("PS4 Right Vertical") : ("Joy Right Vertical"); if (Input.GetAxisRaw(joyRightHoriz) != 0 || Input.GetAxisRaw(joyRightVert) != 0) { var targetX = Input.GetAxisRaw(joyRightHoriz); var targetY = Input.GetAxisRaw(joyRightVert); var angle = Mathf.Atan2(targetY, targetX) * Mathf.Rad2Deg - 90f; rigidBody2d.MoveRotation(angle + turnSpeed * Time.fixedDeltaTime); } // Shoot string joyShoot = (PS4Controller) ? ("PS4 Shoot") : ("Fire1P2"); if (Input.GetAxis(joyShoot) > 0) { Shoot(); } // Move or Dash var moveDirection = new Vector2(Input.GetAxisRaw("HorizontalP2"), Input.GetAxisRaw("VerticalP2")); moveDirection.Normalize(); string joyDash = (PS4Controller) ? ("PS4 Dash") : ("DashP2"); if (Input.GetButtonDown(joyDash) && !isDashing && Time.time > nextDash) { moveSpeed += dashSpeed; Invoke("DashComplete", dashDuration); isDashing = true; nextDash = Time.time + dashCooldown; gameControllerScript.DashP2(dashCooldown); } rigidBody2d.MovePosition(rigidBody2d.position + moveDirection * moveSpeed * Time.fixedDeltaTime); // Reload string joyReload = "ReloadP2";// (PS4Controller) ? ("PS4 Reload") : ("ReloadP2"); if (Input.GetButtonDown(joyReload) && !isReloading && ammoStored > 0) { isReloading = true; gameControllerScript.ReloadP2(reloadDuration); reloadSound.Play(); Invoke("Reload", reloadDuration); } } }