0
\$\begingroup\$

I'm using Unity3d and I'm trying to rotate the left leg bone of an avatar but it is not working although scaling is working well.

This is the code used for scaling and is working perfect:

 r.localScale += new Vector3( 0.1f , 0.1f , 0.1f);

and these are my attempts to is the code of rotation but not working:

 r.eulerAngles = new Vector3(10, 10, 10);                            
 r.rotation = transform.rotation * r.rotation;

where r is the transform of the left leg.

EDIT:

This is my file.

So this doesn't work when I'm using the Update function, like nothing happens to the avatar. If I used LateUpdate function, I can see the rotation made but then flickers back to the old position, I wonder how to apply the rotation to all the remaining frames as well.

If anyone could please advise

\$\endgroup\$

1 Answer 1

1
\$\begingroup\$

Your code doesn't seem to have any "rotation" for me. Plus you're addressing r.eulerAngles, which is why your rotation is failing. Quote from Transform.eulerAngles :

Only use this variable to read and set the angles to absolute values. Don't increment them, as it will fail when the angle exceeds 360 degrees.

And for the next part, what are you expecting this to do? What's transform?

 r.rotation = transform.rotation * r.rotation;

Ayways for rotation, try using :

r.Rotate(new Vector3(10,10,10));

By the way, by addressing r.rotation, you will be addressing the quaternion. Operations on quaternions aren't the same a operations on "Vector3"s.

\$\endgroup\$

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .