- Home /
Execute a script/function after IK
I am trying a unique setup with my character controller. I’m using IK (specifically a Look At IK component from the Final IK plugin) to get the player character model’s head to look at a target.
I need to position an object to be at the same position of the character’s head bone. However, since the IK pass seems to be the last thing that happens in a frame, using LateUpdate does not sample the bone's actual rendered position — only the bone’s position before IK is applied.
Is there a way to execute a script of function after the IK pass, so that I can get the actual positioned data of a bone?
Just doing OnAnimatorI$$anonymous$$ doesn’t seem to help — from what I can tell, it executes before the I$$anonymous$$ pass.
NOTE: $$anonymous$$y setup, specifically, is I am attempting to align the camera to the character’s head. I cannot make the camera a child of the head bone, or else it will pick up all rotations in the character’s idle and move animations. (Picking up the position actually leads to some nice headbob, but the rotations just lead to too much camera jerking).
I could potentially do some math fudging to get the camera to move “just so” to position it where I$$anonymous$$ will end up. But I would like to know how to execute a script after I$$anonymous$$ for any other situation like this that may crop up.
Answer by animalphase · Jun 16, 2015 at 05:39 AM
Of course, immediately after posting this, I found a solution to my problem. I don’t know if this is “proper”, but it seems to work. I will mark as “answered” for now. Reference: http://docs.unity3d.com/Manual/ExecutionOrder.html
I am now updating the camera’s position in OnPreCull(), which fires just before the camera culls the scene. At this time, it is possible to get the position of the bones after the IK pass. It seems safe to move the camera at this time?
However, I’m not yet sure how or if this will effect moving UI elements.
Your answer
Follow this Question
Related Questions
Left Hand IK target is slower than the right 0 Answers
IK for hands 0 Answers
How can I use IK with AnimationClipPlayable or AnimationMixerPlayable? 1 Answer
what is hint and weight in IK? 1 Answer