imagination XD

realizing dream


9 Comments

[Unity] Blendshape Eye Controller (Look At, Random Eyes, and Random Blink)

 

2019 UPDATE

I’ve noticed that Mediafire deleted the original script. Please use this script instead. This script is from my game (Project IMG). I’m sorry if there’s any error happened. This is more updated version and it’s C#

https://drive.google.com/open?id=1uIVj-o5HvuuEr6_oHDRl1Or9umX1Vl9k

Controlling eyes with Unity’s blendshape controller is difficult especially Unity likes to make a blendshape is a float value which harder to control and you can’t even control any movement like down or left. The picture above represents the movement of their eyes. See closely with that cyclops, her eyes were move following that ball, meanwhile the penguin just stuttered with the eye (Random Eye and blink).

You’re gonna need 4 / 5 basic eye blendshapes like Up eye, Right eye, Down eye, Left eye, and blink (optional).

pxeyes nyeyes pyeyes nxeyes

This is very useful tool especially for wannabe animator like me.

Download the script here,

Tutorial

  1. blendeye2
  2. Add this script on the root of your character.
  3. blendeye3
  4. blendeye2aAssign the number / ID of your Blendshape as in your blendshape mesh. I added isDebugging mode, that’ll ease you out finding the number of the blendshape.

  5. blendeye4
  6. After found the right ID, now you’re done! You can control eye movement via 2D Target now. But is that enough ? LOL NOPE!
    blendeye5
  7. To make it focus in 3D Way, create an empty game object and set it as target.
  8. blendeye6
  9. Sometimes this might happens (A certain eye moves in reverse way), to fix it, just invert the blendshape ID like Positive X Axis was 0 and set it to 1 and Negative X Axis was 1 and set it to 0.
    blendeye7
  10. Now look! Your character will focus on that object forever! But if that’s not please you enough, you can use Random Eyes mover (I forgot to make it move along with your target, so it’ll move along with the center of your head). But if you really do want random movement along your target, then just remove “target” line below randomizer target transform.
  11. if(!randomizerTarget){
     randomizerTarget = new GameObject("RNDTRG");
     randomizerTarget.transform.position = blendshapeEyeMesh.transform.position;
     target = randomizerTarget.transform; // remove this
     }else{
     target.position += Random.onUnitSphere * Time.fixedDeltaTime/randomCompressor;
     }
  12. And so do you want them blink ? just turn on Blinkable and your character will be blinkable. The higher value of blink speed the faster it’ll be. And what is Target Multiplier ? That’s just speed multiplier of your 3D target, how fast / sensitive their eye will follow your 3D target.


5 Comments

[Tutorial] Unity Facial Animation / Blendshape / Morph

This is an update from Unity 4.3. This is very amazing feature that I really wanted back then. Realize I don’t know how to make a facial animation with bones. This is very fast method to make a facial animation. Works in Both Unity Indie and Pro. In this tutorial, I split my Head’s mesh and body mesh. It also works if your mesh were joined with head. I split head and body because, blender can’t read my model’s bone.

Unity 4.3 Blendshape

Unity 4.3 Blendshape

So, you’ll require this thing to make a blendshape:

  • Unity3D 4.3 (Download here)
  • Blender 2.69 / Blender 2.68 (Download here)
Launch Blender 2.69 and import your model file.

Launch Blender 2.69 and import your model file.

In Object mode, click your model, then click triangle icon there and on the Shape Keys section, press +

In Object mode, click your model, then click triangle icon there and on the Shape Keys section, press +

After you add new keys, switch it to Edit Mode. That Propositional editing is just used to help you transforms the vertex or should I say, Soft Selection.

After you add new keys, switch it to Edit Mode. That Propositional editing is just used to help you transforms the vertex or should I say, Soft Selection. Remember to set the Key value that you want to edit to 1 and set the other that you don’t want to edit right now to 0.

Shape / Deform your model whatever you like and then name your keys.

Shape / Deform your model whatever you like and then name your keys.

If you want to add / delete keys, you have to switch from Edit Mode to Object Mode. REMEMBER! BEFORE YOU ADD NEW KEYS, MAKE SURE THAT YOUR CURRENT KEY VALUE IS 0 AND YOUR NEW KEY VALUE IS 1

If you want to add / delete keys, you have to switch from Edit Mode to Object Mode. REMEMBER! BEFORE YOU ADD NEW KEYS, MAKE SURE THAT YOUR CURRENT KEY VALUE IS 0 AND YOUR NEW KEY VALUE IS 1

After set the key as many as you want, it's time to Export it to Unity. REMEMBER to SET all keys value to 0! If you don't do this, You'll gonna had a bad time.

After set the key as many as you want, it’s time to Export it to Unity. REMEMBER to SET all keys value to 0! If you don’t do this, You’ll gonna had a bad time.

Import your Exported model to Unity. Unity refuse to read your model? Export it to FBX. Basically, you don't need to adjust everything above. Check if Import Animation is turned on. and then Put it to your scene

Import your Exported model to Unity. Unity refuse to read your model? Export it to FBX. Basically, you don’t need to adjust everything above. Check if Import Animation is turned on. and then Put it to your scene

Set your keys until you happy with it.

Set your keys until you happy with it.

To animate it, Create new Animation Controller and Add Animator component to your character game object. Remember to turn off Apply Root Motion. Create new Animation, then press Add Curve, then select your head game object > Skinned Mesh Renderer > #YOUR KEYS NAME#. and Animate it (set curves). After finished animate, remember to set the animation loop by clicking the animation clip. After that, open your animator controller and insert your animation. Just set it whatever you like. Mine just Idle > EE_Blink. I haven't made talk function yet.

To animate it, Create new Animation Controller and Add Animator component to your character game object. Remember to turn off Apply Root Motion. Create new Animation, then press Add Curve, then select your head game object > Skinned Mesh Renderer > #YOUR KEYS NAME#. and Animate it (set curves). After finished animate, remember to set the animation loop by clicking the animation clip. After that, open your animator controller and insert your animation. Just set it whatever you like. Mine just Idle > EE_Blink. I haven’t made talk function yet.

So what do you think ? Now, it’s done, your model now has a facial animation. Be creative for the further animation and add more realism. If you want a quick lipsync, You can create a script that reads voice frequency and put it to your mouth keys. Like SkinnedMeshRenderer.SetBlendShapeWeight(0,audioFreq);. Read more on Unity’s Scripting Reference about Skinned Mesh Renderer.