#Animating characters with weapons?

1 messages · Page 1 of 1 (latest)

exotic rampart
#

When animating in blender, the characters arms are IK'd to the weapon. This means there's two animations for each motion, for example a run animation would have the body clip and the weapon clip, with the weapon guiding the arms.

Issue is, since I have multiple animation sets in my blender file (Idle, run, strafe, etc) this means the animations don't bake correctly when being imported into unity. What could I do? Do I have to keep every set in a separate blend file?

opal apex
#

You should be able to bake in the different animations into the same fbx file. In Unity, in the Importer under the Animation tab, you should see all the different animation clips.

I usually use the Action Editor in Blender for the different animations

exotic rampart
#

If I leave the weapon in a run animation, and the body in a idle, his arm will be doing a running motion

#

This is fine if there's only one clip each, but once it has to bake more than one for each one it gets out of hand

timid granite
#

IK seems difficult as you lose this information when exporting to unity, unless you maybe regularly animate some ik ponts and set those up as regular animation transform (forward kinematics) in Unity

but I just wanna mention that unity supports animation layers in their animation system, so if you want you can for example decouple the torso motion from the leg motion, so you could play a running animation on the leg layer, and maybe have sword fighting animations on the torso layer, perhaps driven partly by builtin IK or animation rigging package IK

exotic rampart
#

but the issue is, this animation depends on what animation the weapon is doing, since the arm is IK'd to a weapon

#

so a guy running while his weapon isnt moving isnt very good

exotic rampart
#

tbf i can probably just make them all in different files and that would work, but ive got another question

#

Say i've got a guy holding a gun, and he does a little spin with it. Right now, there's two animations, one for the guy's body and one for the gun he's holding

#

but i'm trying to export this to unity, and while i can export the guy no problem, how would the gun animate?

#

do I add a animator to the gun? How would that work? How would I also export the animation that the gun has?

timid granite
#

I might make 2 animators, one one the gun and one on the character
if necessary, the gun is a parent of the hand, or for animations temporarily unparented, since for generic animation the transform hierarchy has to match the one in blender too
and I havea script that controls that the same animations on both animators are played simultaneously, or paremters set etc
I mean you already said you have 2 animations, i don't really know how to handle it in blender.
alternatively you can make just one animation or rig for everything, in unity, if you use humanoid animation type, you go to the import settings and there should be an avatar mask and you enable additional bones there, and also in the character you animate, it should also have these bones. if not, that's tricky. one time i imported a humanoid in blender, added the transform hierarchies i needed, and exported again, so that in unity i could set an avatar mask that included these bones. because avatar masks go by the source transforms of the imported object as references, you can't really add bones at runtime afaik
if you look up avatar masks and import settings

exotic rampart
exotic rampart
#

Like if I just export the weapon as it's animated then it'll look weird because it's animated relative to the guys hand

timid granite
#

information will be relative to the parent,
maybe you can calculate absolute position and make a new animation curve for each position and rotation component and store that as an asset
and make snap shots of the animation each frame while it plays and store that
so I don't really get it,

#

do you mean currently the information is absolute, or relative to the root bone instead of the hand bone?

#

if you don't change that in the animation software,
while i can imagine how to do it in unity it would take a bit of effort
a script that samples the animation, and then calculates the difference between hand and sword transform each frame and stored that somewhere

exotic rampart
#

But in unity I've got it set up so the gun is a child of the guys hand.

#

So the animation data for the gun is absolute, and if I parent it like that then it won't sit in the hand

timid granite
#

because the character you animate it on and the unity character aren't the same (proportions etc)
is there a way in blender to transfer an animation to another bone? can you do something like make an empty transform child for the hand, put the sword animation data into that and export that?

#

otherwise I'd just calculate it in unity
well just is simply said, but it would take a bit of code to calculate relative positions and rotations etc., like i said

#

since you also can't just edit animations from imported fbx files, I might make a copy with ctrl + d of the original animation and put the changed animation curve or added animation for the hand socket of the sword in there