Thursday 15 September 2011

c# - how can we rotate an object 360 degree using Quaternion.euler in unity? -



c# - how can we rotate an object 360 degree using Quaternion.euler in unity? -

i working in unity develop tan-gram game. want rotate object 360 degrees, it's not working. want rotate object through web cam. means when rotate real world object, want game object rotate real world object rotates. using marker real world object. rotating above code. not accurate. it's faster 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; }

c# unity3d quaternions euler-angles

No comments:

Post a Comment