Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

【Look Animator】- Realistic look at target animation for your models!

Discussion in 'Assets and Asset Store' started by FimpossibleCreations, Sep 28, 2018.

  1. FimpossibleCreations

    FimpossibleCreations

    Joined:
    Jun 27, 2018
    Posts:
    537
    Look Animator is component which is animating bones of your character
    to create natural animation of looking at target object.
    There is many features to customize, special variables to make animation
    more smooth, multi-bone support working well with dynamic characters
    or with long necked creatures like dragon etc.

    > Link To Asset Store <

    > User Manual <


    Features:
    ● Includes interactive demo scenes
    ● Includes full source code
    ● Easy setup with enchanced inspector window
    ● Works with humanoid and animal skeletons
    ● Define how many bones you want use and animator gets them automatically
    ● One method to set "moment target" for component to focus on extra target for choosed amount of time
    ● Blend look animation with source animation
    ● Use "Bones' compensation" feature to prevent unnatural arms rotation when looking up or down
    ● Use "Animate with source" feature to keep whole animations motion, very helpful when you need to aim at target and play hit/shot animation, also using it during run or even idle animation makes it look more natural
    ● Turn off/on component with smooth transition by using one method
    ● Make look animation more soft with "Ultra Smoother" feature


    Release video:
     
    Last edited: Oct 2, 2018
  2. FimpossibleCreations

    FimpossibleCreations

    Joined:
    Jun 27, 2018
    Posts:
    537
    Package now is updated to V1.0.1
    - Fixed last back bone no weight error using Spread Value and upgraded it's formula
    - Added compensate positions option for bones compensation
    - Added Backbones rotation offset parameter in correction tab
    - Now when you exceed max rotation angle by clamping range it will highlight in red in the inspector window
    - Some minor upgrades in algorithm
    - Added "Prevent 180 Error" option now for testing, but later it will be probably default enabled option, but needs some more work for versatility
    - Added "Change Target Speed" option under "Limiting" tab, when your character is rotating head too fast or too slow when changing / loosing target you can adjust it here

    > Link To Asset Store <

    Also there is tutorial video for setting up dragon head:
     
  3. kdgalla

    kdgalla

    Joined:
    Mar 15, 2013
    Posts:
    4,616
    Cool! I find that having characters move their heads as if they are looking at something is a simple but highly-effective way to make your character seem more alive.

    I've been using Unity's free head-look-controller script for my project so far. I've written some code on top of it to chose a look-at target based on the characters proximity to viable targets. The only problem I've been having is that when my code switches from has-target to has-no-target, the character's head immediately snaps back to animation's pose with no transition. I've been planning to attempt a work-around at some point, but it sounds like your system has already has a smooth transition for when this happens. Is that right?
     
    kinigeugfrwib likes this.
  4. FimpossibleCreations

    FimpossibleCreations

    Joined:
    Jun 27, 2018
    Posts:
    537
    Thanks :) Yes it have configurable smooth transitioning between targets and bunch of other options to play with ;)
    You can even change target gameObject from inspector window, giving possibility to use it with animated keyframed variables for cutscenes etc.
     
    Last edited: Oct 3, 2018
    kinigeugfrwib likes this.
  5. hiroki1118

    hiroki1118

    Joined:
    Nov 22, 2017
    Posts:
    2
    Why can not I respond to mobile?
    The test on the PC is animating with accurate motion, but this script does not work when playing on the smartphone.
     
  6. FimpossibleCreations

    FimpossibleCreations

    Joined:
    Jun 27, 2018
    Posts:
    537
    Strange, there should be no difference, I will check it, also try to update package, today was approved quick fix for some stuff. EDIT: (I think I know what caused this and it's fixed in update)
     
    Last edited: Oct 5, 2018
    kinigeugfrwib likes this.
  7. hiroki1118

    hiroki1118

    Joined:
    Nov 22, 2017
    Posts:
    2
    thanks!
    It could also be used on the mobile platform.
    I appreciate your update.
    It is perfectly suited to the character of mixamo and I am satisfied
     
    kinigeugfrwib likes this.
  8. kdgalla

    kdgalla

    Joined:
    Mar 15, 2013
    Posts:
    4,616
    @FimpossibleGames, I bought the controller and I really like the way it automatically handles the problem that mentioned in my previous post. It's very smooth and natural.

    I'm having one problem, though. When a character looks down, with the default settings, it's doing this weird vulture-neck thing:

    upload_2018-10-15_12-35-14.png

    I can get rid of this by turning the backbones weight slider and the compensation weight sliders all the way down:
    upload_2018-10-15_12-38-27.png

    I feel like this is not how it's intended to work, though. Any ideas?
     
    kinigeugfrwib likes this.
  9. FimpossibleCreations

    FimpossibleCreations

    Joined:
    Jun 27, 2018
    Posts:
    537
    Hard to tell, probably something with axes setup on neck bones or maybe bone weights, but not likely.
    You can mail me mesh with skeleton (no need for animations) so I can investigate problem.
    But also you should try set some value for "Back bones add offset" under "Correcting rotations" tab, maybe it will be solution but not sure.
     
    kinigeugfrwib likes this.
  10. kdgalla

    kdgalla

    Joined:
    Mar 15, 2013
    Posts:
    4,616
    Thanks, I sent you the FBX file. In the meantime, I will try some of these other settings. I'm interested in fixing any problems with my blender rig, though, so that I can keep re-using it for other characters.

    Edit: Turns out this was just a problem with my blender rig. Thanks to FimpossibleGames for helping me find the issue.
     
    Last edited: Oct 17, 2018
    eaque likes this.
  11. eaque

    eaque

    Joined:
    Aug 20, 2014
    Posts:
    755
    hi, Do you think it is compatible with THird person controller?
    thanks
     
  12. FimpossibleCreations

    FimpossibleCreations

    Joined:
    Jun 27, 2018
    Posts:
    537
    Should be no problem ;)
    Only what you have additionaly to do is movement of main look target point from code or check how it's done in example scenes.
     
    Last edited: Oct 31, 2018
    kinigeugfrwib and eaque like this.
  13. eaque

    eaque

    Joined:
    Aug 20, 2014
    Posts:
    755
    sure!! Thanks!:)
     
    kinigeugfrwib likes this.
  14. DanGxr

    DanGxr

    Joined:
    Dec 27, 2012
    Posts:
    9
    Hi, Ihave purchased Look Animation Asset. Setup is quite simple but i can not get my rig to look at the target . Instead it only looks away from target. ( see LRA anim Unity.jpg )

    Please see attached images one from Unity . Other showing local axes rotaions in Maya.
    I had to uncheck { Animate With Source } to stop random flipping /rotations

    I have tried lots of different setting in the Correcting Rotations settings.
    Im sure there is some offset config that will reverse the rotations .

    Also the target object has to be almost on top of the lead bone before any rotations .
    no matter if i try changing ditance 0 ( infinity ) to higher number . Still the same trigger distance .

    Many Thanks
     

    Attached Files:

    kinigeugfrwib likes this.
  15. FimpossibleCreations

    FimpossibleCreations

    Joined:
    Jun 27, 2018
    Posts:
    537
    Hi Dan, your skeleton looks correct, there is variable "Back Bones Add Offset" in "Correcting Rotations" which can do some stuff here but I think it will not solve whole problem, It's hard to tell what is going on for now, can you send me mesh file with skeleton on mail? Then I can check it precisely.

    If you don't have keyframes on neck bones then you toggle "Animate with source" off, but when you will have some animation here, it's good to turn it on then.

    EDIT:
    So problem here was forward axis of main game object pointing in reversed direction, fixing it solves the problem ;)
     
    Last edited: Dec 2, 2018
    kinigeugfrwib likes this.
  16. joemar_sp

    joemar_sp

    Joined:
    Oct 25, 2017
    Posts:
    4
    Hi! Is there a function to change targets, or turn off look animation via click? Thanks.
     
    kinigeugfrwib likes this.
  17. FimpossibleCreations

    FimpossibleCreations

    Joined:
    Jun 27, 2018
    Posts:
    537
    Not sure what you mean by "via click" but you can check "FLookAnimator_Demo_TriggeredMomentTarget.cs" component which is changing target for LookAnimator when player game object enter trigger collider.

    You have methods like "SetLookTarget", "SetMomentLookTarget" and to turn off look animator you execute method SwitchLooking(false, timeInSeconds)
     
    kinigeugfrwib likes this.
  18. joemar_sp

    joemar_sp

    Joined:
    Oct 25, 2017
    Posts:
    4
    I see..Thank you very much, I just purchased it yesterday so I haven't able to explore all the demos yet..Anyway, it is an excellent asset, fit for my game..:)
     
  19. aburian

    aburian

    Joined:
    Nov 29, 2018
    Posts:
    17
    Curious if this could be used in a boxing game to target the punching?
     
    kinigeugfrwib likes this.
  20. FimpossibleCreations

    FimpossibleCreations

    Joined:
    Jun 27, 2018
    Posts:
    537
    Just for head or to aim arm?
    If for head it could work with some additional controll on some variables through code in certain situations (but I am not totally sure)
    Arm aim could be more difficult but if you would like to use just spine bones to aim it could be easier.
     
    kinigeugfrwib likes this.
  21. The-Creature-Queen

    The-Creature-Queen

    Joined:
    Jan 19, 2017
    Posts:
    24
    Hi, I can make any model or rig but I just can't program. However I'm great at playmaker! And when I say I can't program, the best I can do is paste a premade code to create a custom playmaker action.

    I know it's asking a bit for the price (hey I'm loyal and slowly buying everything that you make, lol!) but could you create a custom playmaker action downloadable on the ecosystem or scripts for me to paste to make them that do the following:
    -Set target character is looking at. (Will snap to an empty game object.)
    -Untarget what character is looking at.

    It only needs a game object slot to target on, that's it. I can work playmaker very very well to chose which target intelligently, I just..can't make the script do the thing.
     
    kinigeugfrwib likes this.
  22. FimpossibleCreations

    FimpossibleCreations

    Joined:
    Jun 27, 2018
    Posts:
    537
    I'm not familiar with play maker, I would need to learn it a little but I planning to do it in future.
    But maybe it will be helpful so you can make playMaker action, you can try just changing variable like inside inspector,
    so lookAnimator.ObjectToFollow = YourTarget; and that's all ;)
    or use method lookAnimator.SetLookTarget(YourTarget);
     
    kinigeugfrwib likes this.
  23. The-Creature-Queen

    The-Creature-Queen

    Joined:
    Jan 19, 2017
    Posts:
    24
    Thanks SO much for the fast reply! And for your kindness in explaining something so simple, yes I can use that with the playmaker's custom action template I think to create a custom action that uses the inspector. (Sorry I meant to buy this thing today as it's a must have, but my SO is the one with the card. lol) I'm chomping at the bit. If I get it to work fine, I'll post the link to download the custom actions so other people can use them with Playmaker.
     
  24. The-Creature-Queen

    The-Creature-Queen

    Joined:
    Jan 19, 2017
    Posts:
    24
    You were right, I didn't even need the custom actions, the inspector property was enough.

    For Playmaker people:
    https://goo.gl/AcVQMw

    Create an FSM on the moving character. Add 'set property.' Drag the look animator script down to the state and select 'Object to Follow' as the property to change. Use whatever means you like to change the target as needed. Works instantly.
     
    kinigeugfrwib likes this.
  25. FimpossibleCreations

    FimpossibleCreations

    Joined:
    Jun 27, 2018
    Posts:
    537
    Look Animator Update 1.0.6
    - Added support for simple eyes follow animation
    - New example model and example scene for LookAnimatorWithEyes component

    > Link to the Asset Store <

     
    kinigeugfrwib likes this.
  26. FimpossibleCreations

    FimpossibleCreations

    Joined:
    Jun 27, 2018
    Posts:
    537
    Look Animator Update 1.0.7
    Added "Bird Mode" under "Additional Control Parameters" tab.
    With this mode you can get Bird-Like laggy rotation and position animation.
    Feature probably will be polished in further updates.

    Griffon GIF

    > Link to the Asset Store <
     
    Last edited: Jan 22, 2019
    kinigeugfrwib likes this.
  27. hungrybelome

    hungrybelome

    Joined:
    Dec 31, 2014
    Posts:
    336
    @FimpossibleGames Is it possible to use this with the "Optimize Game Object" option in the Rig tab if we expose/keep the neck/back bones? I've tried doing so, but then I get this error:

    Code (CSharp):
    1.  
    2. Error during getting parents of LookTarget! (no parent?)
    3. UnityEngine.Debug:LogError(Object)
    4. FIMSpace.FLook.FLookAnimator:GetAdditionalBones(Boolean) (at Assets/FImpossible Games/Look Animator/FLookAnimator.cs:1633)
    5. FIMSpace.FLook.FLookAnimator:OnValidate() (at Assets/FImpossible Games/Look Animator/FLookAnimator.cs:1818)
    6. FIMSpace.FLook.FLookAnimator:UpdateForCustomInspector() (at Assets/FImpossible Games/Look Animator/FLookAnimator.cs:1837)
    7. FLookAnimator_Editor:OnInspectorGUI() (at Assets/FImpossible Games/Look Animator/Editor/FLookAnimator_Editor.cs:265)
    8. UnityEngine.GUIUtility:ProcessEvent(Int32, IntPtr)
    9.  
    10.  
     
    kinigeugfrwib likes this.
  28. FimpossibleCreations

    FimpossibleCreations

    Joined:
    Jun 27, 2018
    Posts:
    537
    I researching but it seems it's not possible to animate bones through code with this option, we can only read the transforms with exposing. This optimization relies on removing possibility to do such things as animating through code.
     
    kinigeugfrwib likes this.
  29. Monil

    Monil

    Joined:
    Apr 24, 2012
    Posts:
    102
    Hi,

    The Animator Component of my character use Animate Physics and I have some problems with FLookAnimator.

    Thanks for your help
     
    kinigeugfrwib likes this.
  30. FimpossibleCreations

    FimpossibleCreations

    Joined:
    Jun 27, 2018
    Posts:
    537
    Hi Monil,

    Thank you for support by buying my package.
    "Animate Physics" are using FixedUpdate() update order, you probably experience sudden changes in rotation etc?
    I am finishing feature to support this just by toggling one variable inside inspector.
    Contact me in PM or mail for update for you.
     
    kinigeugfrwib likes this.
  31. holdingjason

    holdingjason

    Joined:
    Nov 14, 2012
    Posts:
    135
    Hi. Great tool so far but running into an issue that I don't really get. Our characters have ears (generic skels) the ears are subs of the head. The head is setup as the lead bone. The ears have bones as well and animate etc. When the characters moves, rotates, looks around the ears are not following the head like before but seem to be lagging behind the head so they twist and warp. As you can see here. Including below this the other settings and skel setup for this character. Any idea how to fix this? Will post a five star review if we can get this working :)

    upload_2019-5-7_15-23-35.png

    upload_2019-5-7_15-25-11.png
     
    kinigeugfrwib likes this.
  32. FimpossibleCreations

    FimpossibleCreations

    Joined:
    Jun 27, 2018
    Posts:
    537
    So for others: to check your skeleton correctness, you can select head bone in editor mode and rotate it / move, if head isn't moving or other things are moving but no head, that means the weights for bones are setted wrong.
    In this case you can correct it inside modelling software or use neck bone as lead bone.
     
    kinigeugfrwib likes this.
  33. Lewnatic

    Lewnatic

    Joined:
    Sep 29, 2012
    Posts:
    209
    Kinda got the same problem and i fixed it by adding multiple LookAnimators. The problem however is the activation of the lookAt. Because sometimes they are not synchronized. What i now did was creating a little handle script that also allows to switch the lookAt target. The thing i need now is a way to know if a lookAt limit is reached and the leading LookAnimator is activated.

    Is there something like a function state or variable that is for example true if lookAt is interpolating to synchonize all my animators? Something like:

    Code (CSharp):
    1. isLooking = true;
    ... would be cool. Iam currently using.
    using FIMSpace.FLook;

    Cheers.
     
    kinigeugfrwib likes this.
  34. Lewnatic

    Lewnatic

    Joined:
    Sep 29, 2012
    Posts:
    209
    So it seems
    Code (CSharp):
    1. EFHeadLookState lookState
    Is pretty much what I was looking for. Sadly its a protected variable, and I do not really want to change the animators code in case the asset gets updated. Is there a way to check if the animator is looking at things?
     
    kinigeugfrwib likes this.
  35. FimpossibleCreations

    FimpossibleCreations

    Joined:
    Jun 27, 2018
    Posts:
    537
    You can change it to public, I added making this variable public for read in task list.
     
    kinigeugfrwib likes this.
  36. Lewnatic

    Lewnatic

    Joined:
    Sep 29, 2012
    Posts:
    209
    Yeah but then i need to do this every time the asset is updated. Would be cool to have a function inside the script that returns EFHeadLookState lookstates. :>

    There are probably some workarounds like for example checking for local bone rotation changes.

    I added this to the script with a little logic to be called every time the state changes. Would be very useful to have some sort of interface that is checking the look at script states.


    Code (CSharp):
    1.         public EFHeadLookState GetLookStateUpdate(EFHeadLookState Lookstate) {
    2.             return Lookstate;
    3.         }
    Cheers.
     
  37. vegasanx

    vegasanx

    Joined:
    Apr 7, 2019
    Posts:
    31
    Hi, when I want to get characters to stop looking at something I set ObjectToFollow to null. They they look somewhere off to the left (or right) before returning to default position. Why is this?
     
    kinigeugfrwib likes this.
  38. FimpossibleCreations

    FimpossibleCreations

    Joined:
    Jun 27, 2018
    Posts:
    537
    I think I noticed something like this lately but couldn't accurately reproduce it.
    I will dig it more in next days to make fix for it.
     
    kinigeugfrwib and vegasanx like this.
  39. vegasanx

    vegasanx

    Joined:
    Apr 7, 2019
    Posts:
    31
    Thanks! I'll keep a look out for that fix then.
     
    kinigeugfrwib likes this.
  40. Lewnatic

    Lewnatic

    Joined:
    Sep 29, 2012
    Posts:
    209

    Also had a similar problem. But when switched targets.

    I kinda workaround the issue by interpolating to a blend value of 1 which basically has the same effect as setting a look target of null.

    Code (CSharp):
    1.     IEnumerator ExitSmoothLook() {
    2.  
    3.         for (float f = 0f; f <= 1f; f += 0.01f)
    4.         {
    5.             LookComponents [0].BlendToOriginal =  0.1f + f*(f-0.1f);
    6.             LookComponents [1].BlendToOriginal =  0.7f + f*(f-0.7f);
    7.             LookComponents [2].BlendToOriginal =  0.3f + f*(f-0.3f);
    8.             LookComponents [3].BlendToOriginal =  0.3f + f*(f-0.3f);
    9.  
    10.         }
    11.         SetLookAtTarget (target);
    12.         yield return null;
    13.  
    14.     }
    In this example i got a complex rig with multiple lookComponents that all have different BlendToOriginal target values that i want to reach at a time the for loop is finished. This way its possible to synchronize all 4 look at components, which was important in my case. (My rig has creatures with long necks and multiple muscle strands that are outside the neck hierarchy.)

    After interpolation is done. The Target will changed or set to null. This way you can prevent the sudden jerking.
     
    Last edited: May 18, 2019
    kinigeugfrwib likes this.
  41. vegasanx

    vegasanx

    Joined:
    Apr 7, 2019
    Posts:
    31
    Oh thanks but FimpossibleGames PMed me the fix.
     
    kinigeugfrwib likes this.
  42. FimpossibleCreations

    FimpossibleCreations

    Joined:
    Jun 27, 2018
    Posts:
    537
    Fix also will be included in version 1.0.9 which will be available soon
     
    kinigeugfrwib and vegasanx like this.
  43. ProtoPottyGames

    ProtoPottyGames

    Joined:
    Dec 18, 2015
    Posts:
    77
    Hi.
    Just had one more quick thing regarding this one..hehe

    I would like to request that you pleeeease very much NOT do away with the "Prevent 180 Error checkbox" as I very much need to keep that unchecked for several of my use cases. Thank you for your consideration. :)
     
    kinigeugfrwib likes this.
  44. FimpossibleCreations

    FimpossibleCreations

    Joined:
    Jun 27, 2018
    Posts:
    537
    I'm not sure what you mean :( Can you precise it a bit more?

    Updated to V1.0.9:
    - Fixed animation of going back to default pose when target was changed to null or in other situations
    - Added toggle "Animate Physics" (optional parameters tab) to support "Animate Physics" option in Unity's Animator
    - Added new demo example component for focusing on target object within trigger area, with queue feature
     
    kinigeugfrwib likes this.
  45. ProtoPottyGames

    ProtoPottyGames

    Joined:
    Dec 18, 2015
    Posts:
    77
    Sure. :)
    There's a checkbox with a tool tip on it saying something about how the 180° correction thingy may end up being a standard or removed or something instead of a toggle. Just thought I'd chime in about it's usefulness to me before it dissapers or something. ​
     
    kinigeugfrwib likes this.
  46. skinwalker

    skinwalker

    Joined:
    Apr 10, 2015
    Posts:
    509
    Hi,

    Can you change the target automatically and for example the npc will look at the player then at another npc but will prioritize player or the one that is closer?
     
    kinigeugfrwib likes this.
  47. FimpossibleCreations

    FimpossibleCreations

    Joined:
    Jun 27, 2018
    Posts:
    537
    You can do some custom coding for it, here small example how you can do it: https://pastebin.com/30tbWPJy
    But I am working on update where I will include more elegant example of behaviour you suggested ;)
     
    kinigeugfrwib and skinwalker like this.
  48. FimpossibleCreations

    FimpossibleCreations

    Joined:
    Jun 27, 2018
    Posts:
    537
    Updated to version 1.0.91:
    - Some code factoring, new mothods like "TryFindHeadPositionInTarget()" or "GetCurrentTarget()"
    - Few fixes inside inspector windows
    - New example for NPCs prioritizing player's presence to look at
    - New example for gun aiming type of look at animation

     
  49. ProtoPottyGames

    ProtoPottyGames

    Joined:
    Dec 18, 2015
    Posts:
    77
    Excellent.....now I can rip out my ugly solution for prioritizing LookAt.
     
    kinigeugfrwib likes this.
  50. Lewnatic

    Lewnatic

    Joined:
    Sep 29, 2012
    Posts:
    209
    Awesome stuff.
     
    kinigeugfrwib likes this.