Help with making eyes track npcs? (possibly with UV panning?)

So I’m very new to ue4 & still learning a lot.

I want my player character to be able to automatically look at near by objects & npcs.

The character model has oddly shaped eyes that won’t rotate neatly so I thought maybe I could achieve this by
panning the texture around to look like his eyes are moving?

(mind you, I’m open to better suggestions on implementing this.)

Is there a way to get the nearest pawn’s location
then pan the eye texture so that it’s center is facing roughly in the direction of said pawn?

I’m barely at the start of development so I’m open to changes but I want to work this out before I make any
more characters for fear they will would need remade later.


You need mix of blueprints and materials here.

In blueprints get all actors of class (ie get pawns). Then create loop to find closest and check if its in range. If that other pawn is in range, check if it is in view cone (for that calculate dot product of head forward vector and vector from head to pawn).
It that other guy is in cone calculate view at angle for each eye. To get different actors that can be pawns (or objects) create blueprint interface, add it to all classes that you want to focus eyes on, then you can get all actors with interface.

Now create eye material that can be panned, expose U and V offsets as parameters. Create material instance out of that. Then in your character blueprint create Dynamic Material Instance (out of material instance), and apply that dynamic material to eyes. Do some checking and math to calculate how much U and V offset eyes need. Then apply it to eyes material.

I know all above is complicated to do at once, so watch tutorials.