I am trying to achieve functionality where I have a long arm with multiple joints and then some static obstacles in the scene. The arm should be able to reach to a specified target point and avoid collisions or going through any obstacles. So some joints should be bent so that the arm can reach behind obstacles.
How would you solve this problem? Is it possible when using Animation Rigging package for the arm itself?
You could write a custom constraint that would pre-process the control points of your limb constraint (I’m guessing that would be something more than a two bone ik) to adjust around static shapes that you would set as properties in your constraint job. Bounds (Unity - Scripting API: Bounds) would be great as a container for shapes as it’s a blittable struct that will work in C# jobs.
If you’re unfamiliar with custom constraints, you can take a look at this Unite talk:
or take a look at the SIGGRAPH 2019 project where we also have examples of custom constraints:
Could this method work even if the obstacles were not static but moving Rigidbodies instead?
The end application will have a long moving robot arm (with multiple joints) that will grab stuff in areas that are behind static or moving obstacles (i.e. walls, other machinery).
With caveats. You can assign transforms in your custom constraint to retrieve the position of the rigid bodies in the scene, but you’ll always get the information one frame late.
The animation system reads from the scene transform before animating, but the physics system evaluates afterwards (assuming you’ve set the Animator to Update Mode AnimatePhysics).
You can refer to the execution order for more details: