Physics Based Inverse Kinematics

I have an FPS set up where there is simply an arm model pointed out the front of the player. Initially, using the animation rigging package, I made it such that the hand and subsequent joints followed a target. The issue with this is that when moving the target into a wall, for example, the arm will follow. There are two problems with this; one, obviously, being the lack of realism and two being that the game I am making is founded and themed by phyics interactions. To combat this I attempted two things; first, I tried to attach a collider to the target but this lead to strange movement and still some clipping with physical objects. Then, I tried implementing a script that fires raycasts that, every frame, check whether you are interacting with an object but this was expensive and inconsistent.

I have an idea which I feel may work and this is by having a combination of configurable joints, colliders and rigidbodies between the joints of the arm; acting as a ragdoll. Then, the hand would move to the target via interpolation and the upper joints would follow due to the physics joints. I have found this difficult to implement as it is not resistant/stiff like arms and the elbow merely flops around, it also feels very strange.

Suggestions, help or perhaps improvement of the idea I have will be greatly appreciated.

Thanks in advance!

What you are referring to is a concept called an Active Ragdoll, where a physical character uses “muscles” (joint motors) to attempt to move into a position (usually to try to match an animation). Unless you need physics on the arm I would strongly recommend faking it with animation or similar, as active ragdolls are a huge pain to work with (as you have already noticed with the floppy arms, it is very challenging to dial even the basic settings in to behave in a desirable way). Attempting this will likely take more time to implement than the entirety of the rest of your project (I know this from bitter experience).


I would suggest trying something like raycasting in front of the character to see how far away the wall is, and simply animating the character to lower their arm, or something along those lines. Another option would be to increase the size of your characters collider, so that they can never get near enough to a wall that their arm hits it.


If you absolutely must use an active ragdoll, I would recommend looking into assets such as Puppet Master, to do the hard work for you, if you have the budget. I do find that these packages rarely have the level of control you want however so your milage may vary. The alternative is as you guessed, manually dialling in the settings on a configurable joint, and setting the desired target rotations (which is a nightmare to do dynamically)