Distance2D
Usage
This returns the distance from the calling actor to other, disregarding a difference in Z position (if Z difference is wanted, Distance3D can be used). Unlike something like (a.pos-b.pos).length(), this function is portal-sensitive.
Parameters
- other: A pointer to the actor we are getting the distance to.
Return Value
The distance on an XY plane to the other actor.
Examples
This Imp will check if the target is under 128 units away (using the overriding of ZScript Virtual Functions), and if it is, execute code.
Class WaryImp : DoomImp { override void Tick() { if (target && Distance2D(target) < 128) { // if we are less than 128 units away // Code could go here to make the imp less aggressive when the target is close, for example } Super.Tick(); } }
This article is issued from Zdoom. The text is licensed under Creative Commons - Attribution - Sharealike. Additional terms may apply for the media files.