// Update is called once per frame void Update() { if (PauseMenu.IsOn) { return; } float xMov = Input.GetAxis("Horizontal"); float zMov = Input.GetAxis("Vertical"); Vector3 movHorizontal = transform.right * xMov; Vector3 movVertical = transform.forward * zMov; //final movement vector Vector3 velocity = (movHorizontal + movVertical) * speedPlayer; //apply movement motor.Move(velocity); //Rotation HORIZONTAL, we will turn the player to look around him. float yRot = Input.GetAxisRaw("Mouse X"); Vector3 rotationPlayer = new Vector3(0f, yRot, 0f) * lookSensivility; //Apply motor.Rotate(rotationPlayer); //Rotation VERTICAL, we will turn the camera in a vertical axis, why? We dont wanna turn the player vertically only camera. float xRot = Input.GetAxisRaw("Mouse Y"); float cameraRotation = xRot * lookSensivility; //Apply motor.RotateCamera(cameraRotation); //Calculate Jump Vector3 jump = Vector3.zero; //Apply jump Force if (Input.GetButton("Jump")) { jump = Vector3.up * jumpForce; SetJointSettings(0f); } else { SetJointSettings(jointSpring); } motor.ApplyJump(jump); }
// Update is called once per frame void Update() { float xMov = Input.GetAxis("Horizontal"); float zMov = Input.GetAxis("Vertical"); Vector3 movHorizontal = transform.right * xMov; Vector3 movVertical = transform.forward * zMov; //final movement vector Vector3 velocity = (movHorizontal + movVertical) * speed / rb.mass; //apply movement motor.Move(velocity); float yRot = Input.GetAxisRaw("Mouse X"); Vector3 rotationPlayer = new Vector3(0f, yRot, 0f) * lookSensivility; //Apply motor.Rotate(rotationPlayer); //Rotation VERTICAL, we will turn the camera in a vertical axis, why? We dont wanna turn the player vertically only camera. float xRot = Input.GetAxisRaw("Mouse Y"); float cameraRotation = xRot * lookSensivility; //Apply motor.RotateCamera(cameraRotation); Vector3 jump = Vector3.zero; if (Input.GetKeyDown(KeyCode.Space)) { jump = Vector3.up * jumpForce; SetJointSettings(0f); } else { SetJointSettings(jointSpring); } motor.ApplyJump(jump); }