transform.rotate to rotate character's arm
so i have this character in my scene and she is standing in a T pose. i want to use transform.rotate or any other method to rotate her arm so that it is vertical (only one arm) in such a way that first time it goes a little bit up then more and so on. in a way a clock's hour hand moves from 9 to 12. can it be done using a for loop or something ?
This isn't a good idea. Look up some tutorials on $$anonymous$$ecanim or the legacy animation system. It would be a far better use of your time than program$$anonymous$$g every movement.
i am able to animate the hand . no problems in that. i also know in situations like these animations are the goto method but if it can be done as described in the question it would be beneficial because after this i will be using a sensor that will detect the body movement and kind of imitate the movement . for example the sensor will be tied to the arm of a real person and as the person rotates his/her arm the change should be reflected in the game i hope i made sense
Yes, the arm is just a gameObject. Any way to rotate anything else will work on it. arm.Rotate(1,0,0); will totally spin it 1 degree/frame (if you have that in Update). But I doubt that's what you want. You may have to save the "resting" arm rotation, grab the target rotation from the sensor, then SLerp the arm's rotation to the target + arm's resting (something like that).
If the arm is already being animated, you'll need to override that. I think that's LateUpdate.
Answer by I5 · Sep 13, 2018 at 03:13 PM
One solution you could use is IK (inverse kinematics), here's the API, and here's a walk-through of how to use it. You'd could create an invisible object and move that object, like moving the point of a second-hand around a clock face, to where you wanted the character to point to. You can control the speed of the movement by setting the "weight" and "position" of the IK settings.
Another solution would be to check out the "huge mocap" library of humanoid animations (in the asset store), and find an animation that moved the arm the way you wanted, and then cut-down/edit and/or blend that animation. Here's a good list of what the mocap has to offer.
In terms of LOE, the first solution has the lowest, but you may run into limitations with IK (such as the limb just not looking right with respect to the rest of the body). The second solution may provide the better look and feel, and you can also combine the two solutions to work together (IK works in conjunction with the Animator)
A dumbed-down version of this -- move a point from your right side, to over your head, and use arm.LookAt(p). If the arm doesn't have +z running down it, that method still works, buts need a little more math.
I feel like I$$anonymous$$ is for when the target is closer than your reach. It's how much to bend your elbow to make your arm short enough. For just a "reach out", I$$anonymous$$ seems too much.
There's just one movement you're trying to do, right? So "program$$anonymous$$g every movement", based on your requirement, really means just program$$anonymous$$g one movement, one pointing movement. If you read the docs on I$$anonymous$$ and follow the tutorial, it's a very low level of effort. I haven't tried Owen's LookAt solution on a hand/limb though, it may provide and even lower level of effort. Animators and animation, overriding in LateUpdate, that'll surely require the highest level of effort, but also may provide the best look and feel.
yeah . just one movement . either of the arms doesnt matter but the motion has to be in incremental way . say it starts in current position then moves 10 degress then 10 more and so on until it reaches the vertical position where it stops.
Your answer
![](https://koobas.hobune.stream/wayback/20220612174531im_/https://answers.unity.com/themes/thub/images/avi.jpg)