Excerpted from Dane Unity tutorial, infringement is deleted
Examples of common attributes and methods of vector
trigonometric functions to realize AI automatic attack range determination
Take the player vector and AI's own z-axis vector to normalize
Then judge the mold length (length range) first
Do dot multiplication to get the cos value (angle range) judgment
The cross product (cross.y> 0) can be used to determine whether the player is to the left of the enemy