How to calculate AI direction and play animation

This is what I have been trying, but, to no avail…