Vector3 three-dimensional vector

Excerpted from Dane Unity tutorial, infringement is deleted

Insert picture description here
Examples of common attributes and methods of vector
Insert picture description here
Insert picture description here
Insert picture description here
Insert picture description here
Insert picture description here
Insert picture description here
Insert picture description here
trigonometric functions to realize AI automatic attack range determination
Insert picture description here
Insert picture description here
Insert picture description here
Insert picture description here
Insert picture description here
Insert picture description here
Insert picture description here
Insert picture description here
Insert picture description here
Insert picture description here

Insert picture description here
Insert picture description here

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

Insert picture description here

Guess you like

Origin blog.csdn.net/weixin_45401129/article/details/114677545