Can't get Set Look At Position to work

dangoyette

New member
I'm trying to do something very simple: I'm trying to use "Set Look At Position" to make a model look at a given position. Here you can see what I've got so far. The "Target Game Object" is the FXB model that has the Animator on it, which is what is selected in this screenshot.

AnimatorIK.JPG

In the animator, I've set the only layer to support an IK pass:

IKPass.JPG

However, in SetLookAtPosition script, the "OnAnimatorIK" method never gets called. The Update gets called, so this script is executing. But OnAnimatorIK itself is never hit.

Is there some simple thing I'm missing here to make SetLookAtPosition work?
 
You'll want to add a repeater that repeats forever to the top of your task. Right now your behavior tree is only going to execute for one frame and then it'll end.
 
Thanks. That doesn't seem to change the behavior. I've added the repeater, and I've also set the Behavior Tree to Restart when Complete.

Behavior.JPG

I've put a breakpoint in SetLookAtWeight's OnUpdate, and it gets hit every frame. But its OnAnimatorIK doesn't get hit. SetLookAtPosition isn't getting fired at all, since "weightSet" in SetLookAtWeight's is never true (because OnAnimatorIK isn't being called).

I can put a simple script onto the object with the Animator, which just calls SetLookAtPosition and SetLookAtWeight in its OnAnimatorIK(int layer) method, and that works fine. But it's just not getting into the Action's OnAnimatorIK method.
 
Last edited:
I tried this on a different model, and it works better, so I assume there's an issue on my first model, unrelated to Behavior Designer. So, perhaps a false alarm there.

However, on the clean model, I'm finding that OnAnimatorIK is only getting called every other frame, not every frame. I'll keep looking.

Parallel.JPG
 
I think I understand why OnAnimatorIK wasn't working originally for me. The reason is because the Behavior Tree and the Animator were on two different game objects. The Behavior Tree was on the parent game object, and the Animator it was affecting was on a child game object. Even though I properly assigned the Target Game Object, such that it was referencing the game object with the Animator on it, perhaps the OnAnimatorIK code only runs on the same object that has the Behavior Tree on it.

I still don't know why it's only working every other frame when I have the Animator and the BT on the same object, though. But I'll probably just find a different way to set the look target for now.
 
Ahh, yeah, that makes sense. If the current GameObject has no Animator then Unity won't call OnAnimatorIK. I'll remove the Target GameObject field from these IK tasks since it requires the current GameObject.
 
Top