0

I am working in Unity to develop a tan-gram game. I want to rotate an object 360 degrees, but it's not working. I want to rotate my object through web cam. Means when I rotate a real world object, I want game object to rotate as the real world object rotates. I am using a marker as real world object. It is rotating with the above code. But its not accurate. It's faster than the real rotation.

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;
    }
DanM7
  • 2,203
  • 3
  • 28
  • 46

0 Answers0