// Update is called once per frame
    void Update()
    {
        float   _xMov           = Input.GetAxis("Horizontal");
        float   _zMov           = Input.GetAxis("Vertical");
        Vector3 _moveHorizontal = transform.right * _xMov;
        Vector3 _moveVertical   = transform.forward * _zMov;
        Vector3 _velocity       = (_moveHorizontal + _moveVertical).normalized * speed;

        motor.move(_velocity);
        //calculate rotation as a 3d vector
        float   _yRot     = Input.GetAxisRaw("Mouse X");
        Vector3 _rotation = new Vector3(0f, _yRot, 0f) * looksesitivity;

        motor.rotate(_rotation);



        float   _xRot           = Input.GetAxisRaw("Mouse Y");
        Vector3 _cameraRotation = new Vector3(_xRot, 0f, 0f) * looksesitivity;

        motor.rotate(_rotation);
        //apply rotation
        motor.RotateCamera(_cameraRotation);
        Vector3 _thrusterForce = Vector3.zero;

        if (Input.GetButton("Jump"))
        {
            _thrusterForce = Vector3.up * thrusterForce;
        }
        motor.applyThrusterForce(_thrusterForce);
    }
示例#2
0
    void Update()
    {
        //calculate movement velocity as a 3D vector
        float _zmov = Input.GetAxisRaw("Horizontal");
        float _xmov = Input.GetAxisRaw("Vertical");

        Vector3 _movHorizontal = transform.right * _zmov;
        Vector3 _movVertical   = transform.forward * _xmov;

        Vector3 _velocity = (_movHorizontal + _movVertical).normalized * speed;

        // apply movement
        motor.move(_velocity);

        float _yrot = Input.GetAxisRaw("Mouse X");

        Vector3 _rotation = new Vector3(0f, _yrot, 0f) * lookSensitvity;

        //Apply rotation
        motor.Rotate(_rotation);

        // caculate camera rotation as a 3D vector (turning around)
        float _xRot = Input.GetAxisRaw("Mouse Y");

        Vector3 _cameraRotation = new Vector3(_xRot, 0f, 0f) * lookSensitvity;

        //Apply camera rotation
        motor.RotateCamera(_cameraRotation);
    }