void Turning() { float hori = ControllerManager.GetAxis(ControllerInputWrapper.Axis.RightStickX, joystickNum, true); float vert = ControllerManager.GetAxis(ControllerInputWrapper.Axis.RightStickY, joystickNum, true); if (Mathf.Abs(hori) > 0.01f || Mathf.Abs(vert) > 0.01f) { //Debug.Log ("Turning by right analog"); Vector3 direction = new Vector3(hori, 0f, vert); Quaternion newRotation = Quaternion.LookRotation(direction, transform.up); transform.rotation = newRotation; //Quaternion.Lerp (transform.rotation, newRotation, Time.deltaTime * 100f); //Debug.Log ("hori = " + hori); //Debug.Log ("vert = " + vert); } /*Ray camRay = Camera.main.ScreenPointToRay (Input.mousePosition); * * RaycastHit floorHit; * * if(Physics.Raycast(camRay, out floorHit, camRayLength, floorMask)){ * Vector3 playerToMouse = floorHit.point - transform.position; * playerToMouse.y = 0f; * * Quaternion newRotation = Quaternion.LookRotation(playerToMouse); * playerRigidbody.MoveRotation(newRotation); * * }*/ }
void Update() { if (gm.GameInProgress) { dodgeTimer += Time.deltaTime; float h = ControllerManager.GetAxis(ControllerInputWrapper.Axis.LeftStickX, joystickNum, true); float v = ControllerManager.GetAxis(ControllerInputWrapper.Axis.LeftStickY, joystickNum, true); testX = h; testY = v; //Debug.Log ("h = " + h + " v = " + v); if (!disabled) { if (canMove || canTurn) { if (canMove) { maxSpeed = oldMaxSpeed; Move(h, v); } else { speed = 0f; maxSpeed = 0f; } if (canTurn) { Turning(); } } } else { maxSpeed = 0; speed = 0; playerRigidbody.velocity = Vector3.zero; } Animating(h, v); // if((dodgeTimer >= timeBetDodge && Input.GetAxisRaw("PS4_L2_" + playerString) > 0 && dodgeInit == true) || dodgeInit == false){ // Debug.Log("dodge start"); // Dodge(h, v); // } } }
/// <summary> /// Checks the select ability. /// </summary> void checkSelectAbility() { for (int i = 0; i < numPlayers; i++) { if (!ready[i]) { float direct = ControllerManager.GetAxis(ControllerInputWrapper.Axis.LeftStickX, playerControllers[i], true); selectTimer[i] -= Time.deltaTime; //print(direct); if (direct < -0.05f && selectTimer[i] <= 0) { currentAbilitySelected[i] = (--currentAbilitySelected[i]) % allAbilities.Length; scrollAbilitySounds.Stop(); scrollAbilitySounds.Play(); arrows[i * 2].GetComponent <Animator>().SetTrigger("arrowChange"); if (currentAbilitySelected[i] < 0) { currentAbilitySelected[i] += allAbilities.Length; } selectTimer[i] = timeDelay; } else if (direct > 0.05f && selectTimer[i] <= 0) { currentAbilitySelected[i] = (++currentAbilitySelected[i]) % allAbilities.Length; scrollAbilitySounds.Stop(); scrollAbilitySounds.Play(); arrows[i * 2 + 1].GetComponent <Animator>().SetTrigger("arrowChange"); selectTimer[i] = timeDelay; } else if (Mathf.Abs(direct) < .05f) { selectTimer[i] = 0; } } } }
void Update() { CheckSelected(); if (!actionReady) { if (timer < actionDelay) { timer += Time.deltaTime; } else { actionReady = true; } } else { timer = 0f; } //Mouse float directX = ControllerManager.GetAxis(ControllerInputWrapper.Axis.LeftStickX, 1, true); float directY = ControllerManager.GetAxis(ControllerInputWrapper.Axis.LeftStickY, 1, true); switch (currentType) { case ActionType.Play: if (ControllerManager.GetButton(ControllerInputWrapper.Buttons.A, 1, true) || ControllerManager.GetButton(ControllerInputWrapper.Buttons.A, 2, true) || ControllerManager.GetButton(ControllerInputWrapper.Buttons.A, 3, true) || ControllerManager.GetButton(ControllerInputWrapper.Buttons.A, 4, true) && !scrollPanel.isPlaying) { selectAS.Stop(); selectAS.Play(); WhiteOut(); } if (directX < -0.05f || directY < -0.05f && actionReady && !scrollPanel.isPlaying) { scrollAS.Stop(); scrollAS.Play(); currentType = ActionType.Credits; actionReady = false; } break; case ActionType.Credits: if (ControllerManager.GetButton(ControllerInputWrapper.Buttons.A, 1, true) || ControllerManager.GetButton(ControllerInputWrapper.Buttons.A, 2, true) || ControllerManager.GetButton(ControllerInputWrapper.Buttons.A, 3, true) || ControllerManager.GetButton(ControllerInputWrapper.Buttons.A, 4, true) && !scrollPanel.isPlaying) { selectAS.Stop(); selectAS.Play(); creditsPanel.SetActive(true); scrollPanel.isPlaying = true; } if (directX > 0.05f || directY < -0.05f && actionReady && !scrollPanel.isPlaying) { scrollAS.Stop(); scrollAS.Play(); currentType = ActionType.Quit; actionReady = false; } if (directY > 0.05f && actionReady && !scrollPanel.isPlaying) { scrollAS.Stop(); scrollAS.Play(); currentType = ActionType.Play; actionReady = false; } break; case ActionType.Quit: if (ControllerManager.GetButtonAll(ControllerInputWrapper.Buttons.A, true)) { selectAS.Stop(); selectAS.Play(); Application.Quit(); } if (directX < -0.05f || directY > 0.05f && actionReady && !scrollPanel.isPlaying) { scrollAS.Stop(); scrollAS.Play(); currentType = ActionType.Credits; actionReady = false; } break; } }