- Home /
How do you make pupils move along an oval-shaped eye?
I am using Blender to make a character with oval-shaped eyes for a game in Unity and have tried a couple of different techniques for making the pupils move along the surface so that the eyes do not pop out of the sockets when they rotate, however nothing has worked so far.
First, I tried using a lattice to stretch the eye with a damped track constraint on the eye's bone so that it rotated without losing it's oblong shape. Basically this effect.
Next, I tried using a decal attached to an empty in Blender so that it would be like animating a texture with a controlled location over the surface of the eye. Like this tutorial here.
However, when I import my model into Unity using either of these techniques it seems that Unity doesn't work with either of these methods. So what is the typical way to make a character in Unity with oval-shaped eyes? Or is Unity just not capable of doing this?
Answer by Kiloblargh · Dec 17, 2013 at 05:49 PM
I did my eyes by simply adjusting the mainTextureOffset, with a script to translate the direction of the object being looked at relative to the head to x and y values through trial-and-error tweaking until it looked right. Each eye is calculated independently, so they will get more cross-eyed as the look target gets closer. I don't see any reason why this would not work as well on an oval eye or a triangular eye or a rectangular eye or whatever, assuming it is UV mapped properly.
That sounds like what I'm looking for. I'm still on bit confused on how to implement this with a character's animations though. So do you have to control the object being looked at in Unity? Or can it follow a target animated in another 3D program?
I just made an empty transform GameObject centered on each eye and parented to the head. Then the script takes its y rotation relative to the head and uses that to offset the eyeball's texture in the x direction (look left and right) and likewise takes its x rotation relative to the head and uses it to offset the texture in the y direction (look up and down). I'm doing it with transform.LookAt, but the look-at-target null could be a child of the character's root and its position animated in 3DS$$anonymous$$ax (I have no experience importing animations) and still use LookAt in Update() to make the eyes follow it once you put it in Unity.
So you center an empty GameObject on each eye in Unity and code transform.LookAt on the empty. Then do you mean you set it so that the texture follows the rotation of the empty but appears on the surface of the eye? I'm not quite sure how to do that if that is what you mean. I should mention I'm still fairly new to Unity.
And then if you have a bone animated in 3DS$$anonymous$$ax/Blender as a target, how would you tell an object to follow that position when it's in Unity?
I just realized you can just drop the GameObject onto the bone in the armature list. But I'm still not exactly sure what the script should look like so that the texture on the eye follows the GameObject's rotation. Any tips for that?
Your answer
Follow this Question
Related Questions
Blender and unity 1 Answer
Blender to Unity animations not importing correctly 1 Answer
Renaming an animation from FBX format 2 Answers
animation blender to unity problem 0 Answers