Search Unity

  1. Looking for a job or to hire someone for a project? Check out the re-opened job forums.
    Dismiss Notice
  2. Good news ✨ We have more Unite Now videos available for you to watch on-demand! Come check them out and ask our experts any questions!
    Dismiss Notice

Animation Rigging: Avoiding collisions with osbtacles?

Discussion in 'Animation Rigging' started by Haapavuo, Aug 13, 2020.

  1. Haapavuo

    Haapavuo

    Joined:
    Sep 19, 2015
    Posts:
    57
    Hi,

    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?

    Thank you!
     
  2. simonbz

    simonbz

    Unity Technologies

    Joined:
    Sep 28, 2015
    Posts:
    216
    Hi,

    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 (https://docs.unity3d.com/ScriptReference/Bounds.html) 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:
    https://github.com/Unity-Technologies/animation-rigging-workshop-siggraph2019
     
  3. Haapavuo

    Haapavuo

    Joined:
    Sep 19, 2015
    Posts:
    57
    Interesting! I'll take a look into those. Thanks!

    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).
     
  4. simonbz

    simonbz

    Unity Technologies

    Joined:
    Sep 28, 2015
    Posts:
    216
    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:
    https://docs.unity3d.com/Manual/ExecutionOrder.html
     
unityunity