using System.Collections; using System.Collections.Generic; using UnityEngine; public class LG : MonoBehaviour { //LogitechGSDK.LogiControllerPropertiesData properties; private string actualState; public float _LX;//油门 public float _LRZ;//刹车 private Rigidbody rigidbody; // Start is called before the first frame update void Start() { rigidbody= gameObject.GetComponent(); } // Update is called once per frame void Update() { if (LogitechGSDK.LogiUpdate() && LogitechGSDK.LogiIsConnected(0)) { LogitechGSDK.DIJOYSTATE2ENGINES rec; rec = LogitechGSDK.LogiGetStateUnity(0); //油门,0-1 _LX = (float)(-rec.lY + 32767) / (65535); Debug.Log(_LX); rigidbody.AddForce(Vector3.forward*_LX); //刹车 _LRZ = (float)(-rec.lRz + 32767) / (65535); Debug.Log(_LRZ); //Debug.Log(rec.lRz); } } }