public void JumpAndMoveCharacter() { if (playerController.IsOnAMount()) { FindObjectOfType <PlayerController>().gameObject.transform.position = playerMountPos.transform.position; if (cController.isGrounded) { dirPos = transform.forward * Input.GetAxis("Vertical") + transform.right * Input.GetAxis("Horizontal"); if (Input.GetKeyDown(KeyCode.Space)) { if (isWalking && cController.velocity.magnitude == 0) { isWalking = false; playerSoundsManager.StopSound(); } dirPos.y = mountJumpForce; playerSoundsManager.ManageJumpSound(); anim.SetTrigger("Jump"); } } dirPos.y += gravity * Time.deltaTime; cController.Move(dirPos * mountSpeed * Time.deltaTime); } else if (playerController.HasCallTheMount()) { hasSnorted = false; this.transform.position = new Vector3(player.transform.position.x + 2, player.transform.position.y, player.transform.position.z + 2); playerController.SetMountWhistleCall(false); this.transform.LookAt(player.transform); anim.SetTrigger("Call"); } }
//FunciĆ³n que hace que el player se mueva y salte con las ArrowKeys public void JumpAndMoveCharacter() { if (cController.isGrounded) { dirPos = transform.forward * Input.GetAxis("Vertical") + transform.right * Input.GetAxis("Horizontal"); if (Input.GetKeyDown(KeyCode.Space)) { if ((isRunning || isWalking) && cController.velocity.magnitude == 0) { isRunning = false; isWalking = false; soundsManager.StopSound(); } dirPos.y = jumpForce; soundsManager.ManageJumpSound(); } } dirPos.y += gravity * Time.deltaTime; cController.Move(dirPos * moveSpeed * Time.deltaTime); }