x


transform.localRotation problem

if((TMetacarpal.transform.localRotation.y)<TMetacarpalRotationY)

           {

             TMiddle.transform.Rotate(Time.deltaTime*(unflexJointSpeed-60),Time.deltaTime*(unflexJointSpeed-10),0);

             TDistal.transform.Rotate(0,Time.deltaTime*(unflexJointSpeed),0);

             TMetacarpal.transform.Rotate(Time.deltaTime*(unflexJointSpeed-25),Time.deltaTime*-unflexJointSpeed,0,Space.World);

           }

i have a virtual hand model, and i wish to rotate the finger joint to perform a releasing action.

i have use code above to achieve to rotation.

However the TMetacarpal.transform.localRotation.y act weird. Sometime return positive value sometime return negative value.

The correct value should be negative value -0.3360 however sometime it return positive value 0.3360.

Anyone have any idea about it?

more ▼

asked Aug 09 '11 at 05:12 AM

lam meng chun gravatar image

lam meng chun
28 10 10 13

(comments are locked)
10|3000 characters needed characters left

1 answer: sort voted first

It is quite probable that your LOCAL axes are oriented differently from your GLOBAL axes for the finger transform.

easy fix (drawback is that this makes your routine model-dependent):

1- Access the scene view and click on the terrain in drag mode (the arrows forming a cross in unity's topbar). You'll see where each direction arrow points.
2- click on the finger's transform in the instance in the hierarchy, possibly after expanding its root armature (edit time or run time does not matter) and check the direction arrows directions.
3- use the correct axis to perform the rotation, exchanging x, y or z rotation as necessary.

hard fix <= which I suggest only after the easy fix works, and only if necessary, so we'll get to it afterwards

1- store the original finger transform
2- perform a 'SetLookRotation' on the finger transform multiplying it for the original finger transform.
more ▼

answered Aug 09 '11 at 05:24 AM

roamcel gravatar image

roamcel
1.2k 37 40 44

my finger rotation is ok. is just the TMetacarpal.transform.localRotation.y act weird. Sometime return positive value sometime return negative value. it make the if statement not run well. because TMetacarpalRotationY is 0.3360. If TMetacarpal.transform.localRotation.y give me the positive value then my finger rotation will not running.

Aug 09 '11 at 05:41 AM lam meng chun

as i wrote: It is quite probable that your LOCAL axes are oriented differently from your GLOBAL axes for the finger transform. this is a problem that can happen with ALL transforms, and the easy solution works on them all.

Aug 09 '11 at 11:26 AM roamcel
(comments are locked)
10|3000 characters needed characters left
Your answer
toggle preview:

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Topics:

x2244
x25

asked: Aug 09 '11 at 05:12 AM

Seen: 1011 times

Last Updated: Aug 09 '11 at 11:26 AM