0
\$\begingroup\$

I’m working on a top down third person shooter game and was trying to add recoil animations that we can easily tweak through code for all of the different guns available. I wanted to do this through Unity’s animation rigging overrides but was running into some limitations.

Firstly, character models have been set up with optimize game objects enabled in the fbx settings due to which animation rigging straight up refuses to work. As far as I’m aware animation rigging does not work when optimizing game objects is enabled as it expects the default bone hierarchy implementation. enter image description here

I tried to work around this by removing the optimize game objects setting for the character models. This allowed the animation rigging to work but caused the character skins system to break. Basically the current system allows the user to change character skins by replacing the mesh in the skinned mesh renderer. This only works when optimize game objects is enabled for all of the fbx models as it uses the same bone structuring across all fbx files, allowing meshes to be used interchangeably.

Here is the error I get when trying to change the mesh on runtime when optimize game objects is disabled in the fbx settings.

enter image description here

Keeping in mind the limitations I’ve mentioned above, are there any workarounds I can use to get the functionality I desire?

\$\endgroup\$
0

1 Answer 1

0
\$\begingroup\$

My approach to this would be to create the recoil animation in Blender as the most intense one, put it on a separate animation layer in the animator controller and tweak its intensity through the weight of that animation layer.

When multiple animations on different layers affect the same bones, then the layer weights will decide how those animations are blended. So when you have a pose on layer A that places the arms in the neutral position and an animation in layer B that moves the arms from the neutral position to the recoil position and back, then the weight of the lower layer decides how much the arms will move.

You can also sync the speed of the recoil animation with the fire rate of the weapon. You can do that in the animator controller by going to the inspector of the recoil animation state and setting a property to act as a "Multiplier" for the "Speed".

\$\endgroup\$

You must log in to answer this question.

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