示例#1
0
    void Update()
    {
        float xMov = Input.GetAxisRaw("Horizontal");
        float zMov = Input.GetAxisRaw("Vertical");

        Vector3 moveHoriontal = transform.right * xMov;
        Vector3 moveVertical  = transform.forward * zMov;

        Vector3 velocity = (moveHoriontal + moveVertical).normalized * speed;

        motor.Move(velocity);

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

        Vector3 _rotation = new Vector3(0f, yRot, 0f) * SensitvityX;

        motor.Rotation(_rotation);

        float xRot = Input.GetAxisRaw("Mouse Y");

        float _camrotation = xRot * SensitvityX;

        motor.CamRotation(_camrotation);

        Vector3 _thrustFroce = Vector3.zero;

        if (Input.GetButton("Jump"))
        {
            _thrustFroce = Vector3.up * thrustFroce;
            SetJointSetting(0f);
        }
        else
        {
            SetJointSetting(springJoint);
        }

        motor.ApplyForce(_thrustFroce);
    }