- Home /
How to move a characters arm when an animation is playing
So i have a third person character that has a bow, when you hold down right click he starts his aiming animation but if u look up or down his hand doesnt move up or down with where your looking it just points straight, if i try to move a limb the animation stops it from moving so i cant moving his arm up or down. I have tried using a mask on his right hand on the aiming animation layer but it still wont let me move his arm. Im quite new to unity but any help would be appreciated.
Answer by JonPQ · Jun 18, 2018 at 04:26 PM
you can change bones (transforms) manually after the animation update, using IK or code/script to re-position or angle the joint) Check here for UNity's order of updating everything... https://docs.unity3d.com/Manual/ExecutionOrder.html
Here is important part...as regards to animation.
Rigidbody interpolation applies transform.position and rotation OnMouseDown/OnMouseUp etc. events All Update functions Animations are advanced, blended and applied to transform All LateUpdate functions Rendering
To you can modifying a bone in Update or LateUpdate
Get artist to build animation, such that when ai$$anonymous$$g... both the Object root, AND the reference ai$$anonymous$$g node/transform. Are BOTH pointing Forward, and Horizontal (parallel to each other) this is usually along the Z axis.
Apply movement controls, and then do aim/draw animations to your rig. Then in Late Update (after animations have been applied) Change the transform that you want to manually move. Typically I've done this on the waist or a bone above the nice looking parts of the hierarchy. (somewhere in torso or waist) For ai$$anonymous$$g at specific targets.... you can compare normalized vectors Forward out of muzzle, compared to $$anonymous$$uzzle to Target, You can point your waist node at the same vector to aim. (you might need to add/subtract distance between your waist node and muzzle from the target position also otherwise the ai$$anonymous$$g will be off by the same amount.
If targeted ai$$anonymous$$g is still off.. you can tweak the final weapon bone a little in the hand, or shoot the projectile directly at the desired target point even if its slightly off from the facing direction of the weapon, but I try to avoid doing this.
If you are just moving the arm in response to inputs to aim more left/right / up/dn then no need to worry about extra final tweaks to the orientation, but you will need to add angle limits for max x and y rotation. Remember your animation will reset the angle every frame, so every frame you will have to calculate and apply the transform ai$$anonymous$$g (or angle offsets from the base forward ai$$anonymous$$g position)
Thanks for your help. i just used the LateUpdate and a simple look at script to solve this.
Answer by theANMATOR2b · Jun 18, 2018 at 03:02 PM
Are you using generic or humanoid rig setup? Humanoid rig setup animations can not be edited unless using Umotion or other asset from the store. Generic can be modified as needed.
You could create two poses or animations (external animation package) aiming up and aiming down. Set them in a new additive layer and put them in a blend tree. Then blend between the two animations based on the input of the player.
Pointing up = aim up, Pointing down = aim down.
Answer by Invernness · Jun 20, 2018 at 10:12 PM
Im using a Humanoid Rig Setup. Im trying to make animations and using them in a blend tree so if your looking up the up animation is playing and if you looking down then the down animation is playing. Im having trouble lining up the animation and where the player is looking. if the player is looking as high up as he can the bow is just a little lower. Do i have to keep remaking animations til i get the bow to match up? is there any other possible way?
you are never going to get it to aim perfectly (to hit a designated target) using animation blending) This can only get you part way there.... (I've implemented this several times with both guns and bows) (See my answer above)... but basically you can use a combination of blended animations (to get you part way there) Then I$$anonymous$$ (if you want to get really fancy) or direct bone/transform manipulation/pointing. I'll add example to my answer above
Your answer
Follow this Question
Related Questions
TPS Aiming down sights problem 0 Answers
How do I make an aim down sight animation that can be used with mecanim? 2 Answers
How To Play A Different Animation When Bullet Contacts With A Certain Limb? 0 Answers
How to get an animation script working? 1 Answer
Aiming Down the Sights Script (HELP) 0 Answers