Slate Forums › Support › Look at
Tagged: Look at ik
Hello,
I just started to use cinematic sequencer and I’m trying to make an avatar to look at some place while is playing an animation.
If I create an animator controller and use the mecanim track I can enable the IK pass and use the Look At IK. That works good, but I’m trying to use the new Animator Track instead the Mecanim Track. If I use the Animator Track I can’t make the avatar to look at the target I want.
Is there any way to use Animator Track and Look At together?
Hello and welcome 🙂
Animator IK’s are unfortunately only available by Unity when the animator component is using an Animator Controller, which is what the Mecanim Track is doing. The Animator Track though does not at all use an Animator Controller, but rather the new Unity’s “PlayableAPI” and as such IK features are simply non-existent, and the reason why “LookAtIK” action clip can not work with the Animator Track.
Slate though, includes a simple alternative for that, the “Character/Head Look At” action clip, which can also work alongside with the Animator Track. For this clip to work though, you will need to attach the “Character” component on the actor gameobject and set the “Neck” and “Head” references accordingly.
It is a simple Head Look At solution at the moment (No IKs involved)
Let me know if it works for you.
Thanks.
Join us on Discord: https://discord.gg/97q2Rjh
Thank you for your quick response.
I’m trying to use the “Character/Head Look At” action clip. I’ve added the “Character” script to my avatar and I’ve linked the Neck and the Head and when I use the cinematic sequencer “Play button” it works good. However, when I click on Unity “Play buttons” the console displays the error:
MissingReferenceException: The object of type ‘Character’ has been destroyed but you are still trying to access it.
Your script should either check if it is null or you should not destroy the object.
UnityEngine.Component.GetComponentsInChildren[Renderer] (Boolean includeInactive) (at C:/buildslave/unity/build/artifacts/generated/common/runtime/UnityEngineComponentBindings.gen.cs:97)
Slate.CharacterInspector.SetWireframeHidden (Boolean active) (at Assets/ParadoxNotion/SLATE Cinematic Sequencer/Characters/Editor/CharacterInspector.cs:34)
Slate.CharacterInspector.OnDisable () (at Assets/ParadoxNotion/SLATE Cinematic Sequencer/Characters/Editor/CharacterInspector.cs:27)
and when I press the cinematic sequencer play the avatar doesn’t look at the target.
Am I still missing anything?
PD: I attached 2 screenshots
Hey,
So. There are actually two different bugs here.
To fix the null reference exception error although it is harmless, please open up CharacterInspector.cs and change method in line #33 to the following:
1 2 3 4 5 6 7 8 9 |
void SetWireframeHidden(bool active){ if (character != null){ foreach(var renderer in character.GetComponentsInChildren<Renderer>(false)){ EditorUtility.SetSelectedWireframeHidden(renderer, active); } } } |
Then, to fix the reason why the LookAt is not working in play mode, please open up AnimatorTrack.cs and change methods in line #195 to look like the following:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 |
void StoreSet(){ wasController = animator.runtimeAnimatorController; wasRootMotion = animator.applyRootMotion; wasCullingMode = animator.cullingMode; animator.applyRootMotion = useRootMotion; animator.cullingMode = AnimatorCullingMode.AlwaysAnimate; animator.enabled = false; } void Undo(){ if (animator != null){ animator.runtimeAnimatorController = wasController; animator.applyRootMotion = wasRootMotion; animator.cullingMode = wasCullingMode; animator.enabled = true; } } |
The change above relevant to the original file, is basically where the ‘animator.enabled’ line appears.
If you have any trouble with applying the changes above, just drop me an email (support@paradoxnotion.com) and I can send you the modified fixed files instead.
Thanks.
Join us on Discord: https://discord.gg/97q2Rjh
Now works like a charm, thank you