Distance2D
Jump to navigation
Jump to search
Note: This feature is for ZScript only. |
native clearscope double Distance2D(Actor other) const)
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
- Actor 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 in its Tick override, and if it is, execute code.
class WaryImp : DoomImp
{
override void Tick()
{
Super.Tick();
// if we are less than 128 units away:
if (target && Distance2D(target) < 128)
{
// Code could go here to make the imp less aggressive when the target is close, for example
}
}
}