public void mobileInput() { //Debug.Log(canvasManager.instance); float _xMov = canvasManager.instance.joystick.Horizontal; float _zMov = canvasManager.instance.joystick.Vertical; //Debug.Log(_xMov); //Debug.Log(_zMov); Vector3 _movHorizontal = transform.right * _xMov; Vector3 _movVertical = transform.forward * _zMov; Vector3 _velocity = (_movHorizontal + _movVertical).normalized * speed; //apply movement motor.Move(_velocity); //apply the thruster force Vector3 _thrusterForce = Vector3.zero; if (jumpScript.buttonPressed) { if (this.transform.position.y <= 2) { _thrusterForce = Vector3.up * thrusterForce; } } motor.Applythruster(_thrusterForce); GetTouchInput(); Debug.Log(lookInput); if (rightFingerId != -1) { motor.RotateCamera(lookInput.y); Vector3 _rotation = new Vector3(0f, lookInput.x, 0f); motor.Rotate(_rotation); } else { if (lookInputStopping == Vector2.zero) { motor.RotateCamera(lookInput.y); Vector3 _rotation = new Vector3(0f, lookInput.x, 0f); motor.Rotate(_rotation); lookInputStopping = new Vector2(1, 1); } } }
void Update() { //Calculate movement velocity as a 3d Vector float xMov = Input.GetAxisRaw("Horizontal"); float yMov = Input.GetAxisRaw("Vertical"); Vector3 movHorizontal = transform.right * xMov; Vector3 movVertical = transform.forward * yMov; Vector3 velocity = (movHorizontal + movVertical) .normalized * speed; motor.Move(velocity); //animation Animating(xMov, yMov); //Rotation(turning around) float yRot = Input.GetAxisRaw("Mouse X"); Vector3 rotation = new Vector3(0f, yRot, 0f) * lookSensitivity; motor.Rotate(rotation); //Camera Rotation(turning around) float xRot = Input.GetAxisRaw("Mouse Y"); Vector3 camrotation = new Vector3(xRot, 0f, 0f) * lookSensitivity; motor.CameraRotate(camrotation); }
private void Update() { //laskee liikkeen vektorina float xMov = Input.GetAxisRaw("Horizontal"); float zMov = Input.GetAxisRaw("Vertical"); Vector3 movHorizontal = transform.right * xMov; //aina 1välillä -1 - 1 Vector3 movVertical = transform.forward * zMov; //lopullinen vektori Vector3 _velocity = (movHorizontal + movVertical).normalized * nopeus; //normalize koska vektori aina 1 => saadaan suunta vektorille suunta ja nopeudesta nopeus.. // toteuttaa liikeen motor.Move(_velocity); //laskee rotaation vektorina (vaakasuunta) float yRot = Input.GetAxisRaw("Mouse X"); //x akseli koska pyörittää yn ympäri Vector3 _rotation = new Vector3(0f, yRot, 0f) * RotaatioHerkkyys; //Toteuttaa rotaation motor.Rotate(_rotation); //laskee "kameran" rotaation vektorina (pystysuunta) float xRot = Input.GetAxisRaw("Mouse Y"); // y koska pyörittää xn ympäri Vector3 _cameraRotation = new Vector3(xRot, 0f, 0f) * RotaatioHerkkyys; //Toteuttaa rotaation motor.RotateCamera(_cameraRotation); }
private void Update() { float xMove = Input.GetAxisRaw("Horizontal"); float zmove = Input.GetAxisRaw("Vertical"); Vector3 movHorizontal = transform.right * xMove; Vector3 movVertical = transform.forward * zmove; // final movement Vector3 _velocity = (movHorizontal + movVertical).normalized * speed; //apply movement motor.Move(_velocity); float _yRot = Input.GetAxis("Mouse X"); Vector3 _Rotation = new Vector3(0f, _yRot, 0f) * looksensitivity; motor.Rotate(_Rotation); // camera rot calc motor.Move(_velocity); float _xRot = Input.GetAxis("Mouse Y"); float _CameraRotationX = _xRot * looksensitivity; // apply camera rot motor.RotateCamera(_CameraRotationX); Vector3 _thrusterForce = Vector3.zero; //thruster force if (Input.GetButton("Jump")) { _thrusterForce = Vector3.up * thrusterForce; } //thrusterForce apply motor.ApplyThruster(_thrusterForce); }
private void Update() { //stuff to move around float Xmove = Input.GetAxis("Horizontal"); float Zmove = Input.GetAxis("Vertical"); Vector3 moveHorizontal = transform.right * Xmove; Vector3 moveVertical = transform.forward * Zmove; Vector3 velocity = (moveHorizontal + moveVertical) * speed; motor.Move(velocity); // turns player around float yRotate = Input.GetAxisRaw("Mouse X"); Vector3 rotation = new Vector3(0f, yRotate, 0f).normalized *lookSpeed; motor.Rotate(rotation); //camera rotation float xRot = Input.GetAxisRaw("Mouse Y"); float CameraRotationX = xRot * lookSpeed; motor.RotateCamera(CameraRotationX); //thruster force Vector3 force = Vector3.zero; if (Input.GetButton("Jump")) { force = Vector3.up * thrusterForce; setJointSettings(0); } else { setJointSettings(jointSpring); } motor.thruster(force); }
void Update() { //Calculate movement velocity as a 3D vector float _xMov = Input.GetAxisRaw("Horizontal"); float _zMov = Input.GetAxisRaw("Vertical"); Vector3 _movHorizontal = transform.right * _xMov; Vector3 _movVertical = transform.forward * _zMov; //Final movement vector Vector3 _velocity = (_movHorizontal + _movVertical).normalized * speed; //Apply movement motor.Move(_velocity); //Calculate rotation as a 3D vector (Turning around) float _yRot = Input.GetAxisRaw("Mouse X"); Vector3 _rotation = new Vector3(0f, _yRot, 0f) * lookSensitivity; // Apply rotation motor.Rotate(_rotation); //Calculate camera rotation as a 3D vector (Turning around) float _xRot = Input.GetAxisRaw("Mouse Y"); float _cameraRotationX = _xRot * lookSensitivity; // Apply rotation motor.Rotate(_rotation); motor.RotateCamera(_cameraRotationX); // Unlock the mouse pointer when ESC is pressed //if (Input.GetKeyDown("escape")) // Cursor.lockState = CursorLockMode.None; }
void Update() { float _xMov = Input.GetAxisRaw("Horizontal"); float _yMov = Input.GetAxisRaw("Vertical"); Vector3 _movHorizontal = transform.right * _xMov; Vector3 _movVertical = transform.forward * _yMov; Vector3 _velocity = (_movHorizontal + _movVertical).normalized;// * speed; motor.Move(_velocity); //left right turning float _yRot = Input.GetAxisRaw("Mouse X"); Vector3 _rotation = new Vector3(0f, _yRot, 0f) * sensitivity; motor.Rotate(_rotation); //up down looking float _xRot = Input.GetAxisRaw("Mouse Y"); Vector3 _cameraRotation = new Vector3(_xRot, 0f, 0f) * sensitivity; motor.RotateCamera(_cameraRotation); if (audioSource != null) { //play footsteps with interval based on player speed float timeInterval = 0f; if (!(motor.Velocity.x == 0f && motor.Velocity.z == 0f)) { float x = motor.Velocity.x; float z = motor.Velocity.z; if (x < 0) { x *= -1; } if (z < 0) { z *= -1; } if (x > 0.001 && z > 0.001) //so you don't take steps when basically not moving at all { timeInterval = 1 / (x + z); if (timeInterval > 2f) //so you don't end up with more than 2s delay between steps { timeInterval = 2f; } } else { timeInterval = 0f; } } else { timeInterval = 0f; } float time = Time.time; if (time >= nextPlay && timeInterval != 0f) { nextPlay = time + timeInterval; audioSource.Play(); } } }