Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. Dismiss Notice

[RELEASED] Realistic Eye Movements

Discussion in 'Assets and Asset Store' started by Faikus, Feb 12, 2015.

  1. Fangh

    Fangh

    Joined:
    Apr 19, 2013
    Posts:
    246
    My LookAtPlayerRatio is set to 1 but it is clearly looking on the right of my camera. Why ?
    upload_2022-12-20_16-40-38.png
     

    Attached Files:

  2. Fangh

    Fangh

    Joined:
    Apr 19, 2013
    Posts:
    246
    It was because my eyes were incorrectly setup. I setup them with blendshape but the documentation says it needs to be setup with transform. now it is working !
     
  3. mroshaw

    mroshaw

    Joined:
    Oct 11, 2020
    Posts:
    34
  4. Faikus

    Faikus

    Joined:
    Jan 3, 2011
    Posts:
    228
    REM unfortunately doesn't support eye movement via blendshapes. What you can do is to replace the blendshape eyes with separate eyeball models that you parent to the head bone (there are many high quality eyes on the Asset store , like Eyes Advanced). If the current eyes are part of the overall body mesh, you can do that by either cutting out the eye polygons in a 3D modelling tool, or by modifying the texture that shows the eyes to only show 0 transparency in the place of the eyes, and then use a cutout shader.
     
  5. mroshaw

    mroshaw

    Joined:
    Oct 11, 2020
    Posts:
    34
    What I've tried to do is add "dummy" eyeball GameObjects to the model, controlled by REM. I'm writing a custom script component to translate the REM controlled eye rotations to corresponding float values in my Blendshapes.

    Getting an NRE from REM for some reason, seems it not enough just to set up Game Objects. REM seems to be expecting something else in the hierarchy that I haven't figured out yet, though seems to be related to Animator or bones in the model.
     
  6. Faikus

    Faikus

    Joined:
    Jan 3, 2011
    Posts:
    228
    In the Setup section, set Eye Control to Selected Objects and then assign your eye objects to the appearing slots. If you still get a NRE, please tell me what script and line number the error message puts out.
     
    mroshaw likes this.
  7. mroshaw

    mroshaw

    Joined:
    Oct 11, 2020
    Posts:
    34
    Thank you!

    I've tried again and still get an NRE:

    Code (CSharp):
    1. NullReferenceException
    2. UnityEngine.Transform.set_localRotation (UnityEngine.Quaternion value) (at <4746c126b0b54f3b834845974d1a9190>:0)
    3. RealisticEyeMovements.EyeRotationLimiter.RestoreDefault () (at Assets/RealisticEyeMovements/Scripts/Internal/EyeRotationLimiter.cs:145)
    4. RealisticEyeMovements.ControlData.RestoreDefault (System.Boolean withEyelids) (at Assets/RealisticEyeMovements/Scripts/Internal/ControlData.cs:858)
    5. RealisticEyeMovements.EyeAndHeadAnimator.InitializeEyes () (at Assets/RealisticEyeMovements/Scripts/EyeAndHeadAnimator.cs:1058)
    6. RealisticEyeMovements.EyeAndHeadAnimator.Initialize () (at Assets/RealisticEyeMovements/Scripts/EyeAndHeadAnimator.cs:996)
    7. RealisticEyeMovements.EyeAndHeadAnimator.MakeSureIsInitialized () (at Assets/RealisticEyeMovements/Scripts/EyeAndHeadAnimator.cs:1238)
    8. RealisticEyeMovements.EyeAndHeadAnimator.Update () (at Assets/RealisticEyeMovements/Scripts/EyeAndHeadAnimator.cs:1589)
    Debugging the code, it's happening in the `EyeRotationLimiter` class, as the "transform" field is null.
     
  8. mroshaw

    mroshaw

    Joined:
    Oct 11, 2020
    Posts:
    34
    Ignore me, rookie mistake! Had another NPC that was configured incorrectly, causing the errors. My fault entirely! All good!
     
  9. Dalenc

    Dalenc

    Joined:
    Jun 24, 2015
    Posts:
    15
    Will the asset have presets for Daz Genesis 9?
     
  10. Faikus

    Faikus

    Joined:
    Jan 3, 2011
    Posts:
    228
    Yes definitely! Here is the preset for G9 with eyelid bone control: [link]
     
    Dalenc likes this.
  11. Dalenc

    Dalenc

    Joined:
    Jun 24, 2015
    Posts:
    15
    Thank you very much
     
  12. thubbardnd

    thubbardnd

    Joined:
    Jan 23, 2021
    Posts:
    1
    Has anyone come across this error before?

    Assets\RealisticEyeMovements\Scripts\Internal\DestroyNotifier.cs(13,40): error CS0066: 'DestroyNotifier.OnDestroyedEvent': event must be of a delegate type


    upload_2023-2-10_15-48-43.png upload_2023-2-10_15-48-43.png
     
  13. Faikus

    Faikus

    Joined:
    Jan 3, 2011
    Posts:
    228
    Have you redefined the "Action" class somewhere in your code? Does the error go away if you replace "Action" with "System.Action" in line 13 of Scripts/Internal/DestroyNotifier.cs?
     
  14. timohubbard

    timohubbard

    Joined:
    Mar 12, 2022
    Posts:
    5
    I haven't redefined Action, but I will replace the Action with System.Action. I'll write back to let everyone know in case it comes up again. Thank you!
     
  15. timohubbard

    timohubbard

    Joined:
    Mar 12, 2022
    Posts:
    5
    That worked, using System.Action Thank you!
     
    Faikus likes this.
  16. Michal_Stangel

    Michal_Stangel

    Joined:
    Apr 17, 2017
    Posts:
    148
    Hello, I sometimes get these errors (enclosure) being spammed when pausing game by setting Time.timeScale = 0. Is there a way on my side to prevent it (except not changing timeScale :) )?
     

    Attached Files:

  17. Faikus

    Faikus

    Joined:
    Jan 3, 2011
    Posts:
    228
    In EyeAndHeadAnimator.cs, in line 1715, so at the beginning of the function UpdateEyeMovement, please insert these lines:
    Code (CSharp):
    1. if ( deltaTime == 0 )
    2.      return;
    This will be fixed in the next update.
     
  18. Michal_Stangel

    Michal_Stangel

    Joined:
    Apr 17, 2017
    Posts:
    148
    Great, thank you!
    Your asset is brilliant.
     
    Faikus likes this.
  19. mroshaw

    mroshaw

    Joined:
    Oct 11, 2020
    Posts:
    34
    Hi! This is going to sound like a really stupid question, but can you tell me where I configure the Blendshapes in the component settings? Thanks!
     
  20. Michal_Stangel

    Michal_Stangel

    Joined:
    Apr 17, 2017
    Posts:
    148
    Last part of authors tutorial is detailed setup of DAZ character (using blendshapes):
     
  21. rmfoley92

    rmfoley92

    Joined:
    Jun 26, 2022
    Posts:
    3
    I've downloaded this package but having issues deploying it on Mixamo charcters, I just get the following error:

    Cannot import, eye control set to Mecanim eyes, but left eye not found.

    Character animation type is set to humanoid and other animations are working fine with it. Everything seems set up properly but as soon as I go to import the MixamoFuse.json it throws up the error
     
  22. Faikus

    Faikus

    Joined:
    Jan 3, 2011
    Posts:
    228
    The eye bones are probably not assigned in the Mecanim Humanoid setup. Just assign them in the import settings of the fbx and it should work.
     
  23. rmfoley92

    rmfoley92

    Joined:
    Jun 26, 2022
    Posts:
    3
    Thanks for Replying

    You'll have to forgive me because I'm new to Unity Development, but I have no idea how to assign the eye bones on the import settings!
     
  24. Faikus

    Faikus

    Joined:
    Jan 3, 2011
    Posts:
    228
    Click on the fbx file, then in the inspector in the "Rig" tab make sure the type is set to humanoid, then click configure, then on "Head" and fill the slots for the eyes.
     
  25. jpileborg

    jpileborg

    Joined:
    Jan 5, 2013
    Posts:
    18
    I'm using Infinity PBR human characters, and followed the instructions in this video. Eye movement works fine, but not blinking.

    Instead of closing the eyelids to the positions I set, it seems to be moving the eyelids in the opposite directions. And looking through the JSON file, no value seem to match the ones I set for the closed eyelid angles.

    Is this something anyone have experienced before, with any character model?
     
    Last edited: Jun 6, 2023
  26. Faikus

    Faikus

    Joined:
    Jan 3, 2011
    Posts:
    228
    In the editor outside of Play mode, in the EyeAndHeadAnimator component in the Setup section, when you click on the Load button for Eyes Closed, does the character close the eyes correctly?
     
  27. zinnercircus

    zinnercircus

    Joined:
    Jul 13, 2013
    Posts:
    8
    Anyone have any insights into getting the saved json file to load via StreamingAssets directory for the Quest 2? Works in editor but never works when building the APK. Any help is appreciated!

    Code (CSharp):
    1. #if UNITY_EDITOR || UNITY_STANDALONE
    2.                 EyeAndHeadAnimator eyeAndHeadAnimator = gameObject.AddComponent<EyeAndHeadAnimator>();
    3.                 eyeAndHeadAnimator.ImportFromFile(Application.streamingAssetsPath + "/REMsettings.json");
    4.                 LookTargetController lookTargetController = gameObject.AddComponent<LookTargetController>();
    5.                 lookTargetController.Initialize();
    6. #else
    7.         StartCoroutine(LoadPreset("remsettings.json", gameObject));
    8. #endif
    9.  
    10.     }
    11.  
    12.     IEnumerator LoadPreset(string presetFilename, GameObject newCharacterGameObject)
    13.     {
    14.         string path = "jar:file://" + Application.dataPath + "!/assets/" + presetFilename;
    15.         WWW loadPreset = new WWW(path);
    16.  
    17.         yield return loadPreset;
    18.  
    19.         string newPath = Application.persistentDataPath + "/" + presetFilename;
    20.         File.WriteAllBytes(newPath, loadPreset.bytes);
    21.         EyeAndHeadAnimator eyeAndHeadAnimator = newCharacterGameObject.AddComponent<EyeAndHeadAnimator>();
    22.         eyeAndHeadAnimator.ImportFromFile(newPath);
    23.         LookTargetController lookTargetController = newCharacterGameObject.AddComponent<LookTargetController>();
    24.         lookTargetController.Initialize();
    25.     }
     
    Last edited: Jun 16, 2023
  28. Faikus

    Faikus

    Joined:
    Jan 3, 2011
    Posts:
    228
    You have "REMsettings.json" for standalone, and "remsettings.json" for Android. The filesystem is case sensitive, so you need to change the second to "REMsettings.json".
     
  29. zinnercircus

    zinnercircus

    Joined:
    Jul 13, 2013
    Posts:
    8
    Great catch! and unfortunately still no dice. I have verified the file and references are all lowercase now and still have no luck on the Quest 2. I appreciate the eyes though! (no pun intended!) lol
     
  30. Faikus

    Faikus

    Joined:
    Jan 3, 2011
    Posts:
    228
    I have tried the exact code you posted and after replacing the it with "REMsettings.json" it works. What is the problem you encounter? Can you install the package Android Logcat from the Package Manager Unity Registry tab and see whether there are some error messages?
     
  31. zinnercircus

    zinnercircus

    Joined:
    Jul 13, 2013
    Posts:
    8
    Wow, I really don't understand why but it totally fixed it. Thank you!!! that was driving me crazy! Even when all references and files where lowercase, it didn't work, but tried your suggestion and whala! thank you!
     
  32. wechat_os_Qy07pQU3y2Exl8tqZzEP8oKa0

    wechat_os_Qy07pQU3y2Exl8tqZzEP8oKa0

    Joined:
    Jul 28, 2023
    Posts:
    2
    Hi! I am wondering if I could get the value of rotations in real-time when the head or eyes are moving?
     
  33. Faikus

    Faikus

    Joined:
    Jan 3, 2011
    Posts:
    228
    You can always just query the eye bones or head bone each frame, as that's what REM is moving. Or do you mean something more specific?
     
  34. wechat_os_Qy07pQU3y2Exl8tqZzEP8oKa0

    wechat_os_Qy07pQU3y2Exl8tqZzEP8oKa0

    Joined:
    Jul 28, 2023
    Posts:
    2
    Thanks for your reply. I mean, is it possible to get the rotation value before the head moves to a certain point? For example, I set a point of interest, and what I want is the rotation value that takes the head to that point.
     
  35. Faikus

    Faikus

    Joined:
    Jan 3, 2011
    Posts:
    228
    Ah I see. That's not all in one spot that can be queried, because most computations happen in head or eye forward space, and later the calibrated rotation forward offset is taken into account, that is, the offset that comes from the eye bones usually not pointing exactly into the eye forward direction etc.
     
  36. klobbi1212

    klobbi1212

    Joined:
    Feb 20, 2018
    Posts:
    7
    Hello,
    i have a problem with REM, the eyes are rotated after importing the DAZ Preset.
    my workflow is DAZ-<Blender. After deleting the useless stuff and root bone i import the changed blender file into unity. I follow this workflow, because this makes it possible to use DAZ Posecontrols in unity.

    So, here is the character before using the REM import of the DAZ Preset: before.png
    and after the import:
    after.png
    Do you know where i have to adjust the rotation ? I tried it at various places without success.
    Thank you...
     

    Attached Files:

  37. klobbi1212

    klobbi1212

    Joined:
    Feb 20, 2018
    Posts:
    7
    after I edited some parameters in the json file
    to
    "eyeRoot_From_leftEyeAnchor_Q": {
    "x": 0.0,
    "y": 90.0,
    "z": 90.0,
    "w": 1.0
    },
    "eyeRoot_From_rightEyeAnchor_Q": {
    "x": 0.0,
    "y": 90.0,
    "z": 90.0,
    "w": 1.0
    },
    the eyes are rotated when the animation is in running, only problem is, that the Eye position is a bit weird. for example the eyelashes are not quite visible .
    aftereditingjson.png
     
  38. Faikus

    Faikus

    Joined:
    Jan 3, 2011
    Posts:
    228
    Does the original preset work on the DAZ char before the Blender step? Maybe you are not using the correct preset for that DAZ generation? What DAZ generation is the character, and which preset did you use?

    If the Blender step is responsible for the preset not matching, you should create a new preset once from scratch as described in the Readme or the Quickstart video, and save it so you can use that instead on your other figures that also go through the Blender step.
     
  39. klobbi1212

    klobbi1212

    Joined:
    Feb 20, 2018
    Posts:
    7
    Sorry Faikus,
    i must confess that I stopped watching when i reached the Preset part :) .
    with the manual setup everything is working correctly.
    Thank you very much !