Search Unity

Raycast from IAnimationJob.ProcessAnimation()

Discussion in 'Scripting' started by littlepolygon, Dec 2, 2019.

  1. littlepolygon

    littlepolygon

    Joined:
    Jul 7, 2013
    Posts:
    16
    I'm trying to write an animation job that performs foot-fixup against terrain as part of a PlayableGraph. However, both Physics.Raycast() and RaycastCommand.ScheduleBatch() complain about not being on the main thread.

    What's the correct way to raycast from the playable thread? If not, is there a way to synchronize with the main thread? Or else, what's the best place to request support, since this would be a high-value feature for a number of animation problems.
     
  2. littlepolygon

    littlepolygon

    Joined:
    Jul 7, 2013
    Posts:
    16
    Point of clarification: the foot location that we're querying-from is coming from the AnimationStream itself -- we're adjusting the incoming animation-pose with ik, so the position isn't known before the playable-graph kicks-off evaluation.
     
  3. littlepolygon

    littlepolygon

    Joined:
    Jul 7, 2013
    Posts:
    16
    Attempting to use PlayableBehaviour.ProcessFrame() as a hook appears to be no-bueno, since it's attached to an AnimationPlayableOutput rather than a ScriptPlayableOutput, and therefore doesn't run.
     
  4. littlepolygon

    littlepolygon

    Joined:
    Jul 7, 2013
    Posts:
    16
    For reference, here's the log from attempting to raycast through the job system.