我在Unity工作,开发一款棕褐色的游戏。我想将对象旋转360度,但它不起作用。我想通过网络摄像头旋转我的对象。意味着当我旋转真实世界物体时,我希望游戏物体在真实世界物体旋转时旋转。我使用标记作为现实世界的对象。它正在旋转上面的代码。但它不准确。它比实际轮换更快。
void Update ()
{
if (NyARWebCam == null) {
return;
}
NyARWebCam.update ();
NyARMarker.update (NyARWebCam);
bool checkMarker = NyARMarker.isExistMarker (mId);
bool checkMarker2 = NyARMarker.isExistMarker (mId2);
string s = "", pos = "", p = "";
float firstMarker = 0f, secondMarker = 0f;
if (checkMarker) {
NyARMarker.getMarkerTransform (mId, ref markerPosition1, ref markerRotation);
if (count1 == 0) {
float temp = (markerPosition1.z + actualZ);
applyZ1 = (markerPosition1.z - temp) + 50;
newZ1 = temp;
count1++;
} else {
applyZ1 = (markerPosition1.z - newZ1) + 50;
}
applyX1 = markerPosition1.x/2;
b.transform.position = Vector3.Lerp (b.transform.position, new Vector3 (-applyX1, 36.98051f, 36.98051f), 0.5f * Time.deltaTime);
float n = 1.0f;
n =(float) (markerRotation.x* Mathf.Rad2Deg);
Debug.Log (n);
b.transform.rotation = Quaternion.Euler (n*(n/8), 90, 0);
pos = "" + applyZ1;
firstMarker = applyX1;
}