Code archives/3D Graphics - Misc/Point an Entity at x,y,z

This code has been declared by its author to be Public Domain code.

Download source code

Point an Entity at x,y,z by Chroma2002
I'm darn sure this is the fastest method.
;===========================
;Point Entity at x,y,z
;===========================
Function Point_Entity(entity,x#,y#,z#)
	xdiff# = EntityX(entity)-x#
	ydiff# = EntityY(entity)-y#
	zdiff# = EntityZ(entity)-z#
	dist#=Sqr#((xdiff#*xdiff#)+(zdiff#*zdiff#))
	pitch# = ATan2(ydiff#,dist#)
	yaw#   = ATan2(xdiff#,-zdiff#)
	RotateEntity entity,pitch#,yaw#,0
End Function
;===========================

Comments

None.

Code Archives Forum