That’s the basic idea: get a vector from the animal to the fpc (toFpcDir) and check the angle between -toFpcDir (a vector from the fpc to the animal) and the fpc forward direction; if it’s less than some narrow angle (15, in the pseudo code below) the fpc is looking in the animal direction, thus make it beat the road; if greater than this angle, continue moving in the fpc direction until a minimum distance is reached, when you could do the attack and apply damage - something like this (animal script):
var fpc: Transform; // drag the First Person Character here
function Update(){
var toFpcDir = fpc.position - transform.position; // animal->fpc direction
var angle = Vector3.Angle(-toFpcDir, fpc.forward); // check the angle
if (angle < 15){ // FPC is facing the animal:
// run away or go back
} else { // FPC is looking to other direction:
// continue and attack
}
}
The actual movement of the animal will depend on which kind of object it is. Usually live creatures are based on a CharacterController, thus you should move it with Move or SimpleMove, taking advantage of the calculated toFpcDir vector. You must also decide what exactly the animal will do when the fpc look at it: go back slowly, or turn 180 degrees and run, or a mix of the two things etc.