0
\$\begingroup\$

I have a rapid fire weapon that I made in blender, along with a FPS mesh and rig. I'm currently at the stage when I'm creating animations (idle, aim, etc), and had this question: Should recoil be an animation or script?. I decided to go with scripted recoil as originally planned, but see one potential problem going this route that I don't know how to solve.

If I were to use scripted recoil, how do I keep the hands on the gun?

The rig in blender is as follows:

An "arms mesh" (consists of the left and right arm)

An "FPS armature" (Typical rig for an arms only armature, upper hand bone, lower hand bone, fingers, etc)

An rifle mesh (broken down into different parts, ie, barrel, body, stock, magazine, etc)

A rifle armature (gun bone, magazine bone)

A "weapon holder" empty

The FPS armature has Inverse Kinematics on the bone that controls the palm/hand area of the mesh. The weapon holder has a child of constraint that makes it a child of the "hand bone". The "gun bone" on the rifle armature, has a child of constraint that makes it a child of the "weapon holder". The left hand Inverse Kinematic target also has a child of constraint that makes it a child of the weapon holder, so that the left hand follow the barrel of the gun.

The FPS armature has different animations like an idle animation, weapon draw animation, etc. I'm also considering adding a "fire animation", since I figured I'd need an animation where there is no hand movement at all so that I can have the gun be steady while the recoil script rotates the gun over in unity.

The only animation the gun would have is the reload animation where the magazine floats out of the gun and goes back in.

I plan to export the gun and FPS armature separately into unity, and have this weapon, along with a few others I created, be a child of the hands.

Is there any way I can keep the hands on the weapon when I have scripted recoil in Unity?

I haven't actually encountered the problem yet, since I'm still making the animations, but going the route I'm taking, I'm fairly sure I'm going to come across it later on. Since I'm still at the early stages, if anyone has critique or advice on how I set my rig and stuff, I can still change it, so any input is apreciated.

\$\endgroup\$
6
  • 2
    \$\begingroup\$ This is usually exactly what the inverse kinematics link between the hand and grip points on the gun is meant to achieve. Is an IK solution not appropriate for your needs? \$\endgroup\$
    – DMGregory
    Commented Nov 9, 2020 at 18:25
  • \$\begingroup\$ I'm pretty new to unity and blender and just recently learned about it through a comment in my original question. I'm still looking into it, but I think it might do the trick. \$\endgroup\$
    – KI.
    Commented Nov 9, 2020 at 18:30
  • 1
    \$\begingroup\$ It might be a little premature to ask this question then. Want to finish a quick & dirty test, and then revive this question with specifics of where the test goes wrong (if it fails)? \$\endgroup\$
    – DMGregory
    Commented Nov 9, 2020 at 18:32
  • 1
    \$\begingroup\$ Did you really program your recoil script in the old and obsolete UnityScript programming language? You should really use C# instead. Or if you are already using C#, you should remove the unityscript tag from your question. \$\endgroup\$
    – Philipp
    Commented Nov 9, 2020 at 22:52
  • 1
    \$\begingroup\$ Thanks for pointing that out, I use C# for my scripts. I didn't even know there was a UnityScript language. I just put the tag because I though unity script meant C# scripts in unity. \$\endgroup\$
    – KI.
    Commented Nov 10, 2020 at 0:12

0

You must log in to answer this question.

Browse other questions tagged .