Talk:Enemy AI That Follows The Character Done Right/@comment-5334617-20150609214702

Trigonometry can be avoided entirely:

[code] deltaX=characterX-enemX deltaY=characterY-enemY enemDistance=sqrt(deltaX*deltaX+deltaY*deltaY) if (enemDistance<1) then goto @collision enemVelX=(enemVelX+deltaX/enemDistance*0.1)*FRICTION enemVelY=(enemVelY+deltaY/enemDistance*0.1)*FRICTION [/code]

Incidentally, the variable named [code]FRICTION[/code] is the opposite of friction: a value of [code]1[/code] means no friction at all, and lower values correspond to increasing friction. The acceleration is also a function of the variable [code]FRICTION[/code], though it is not in physics.