DirTo Method

See Also Applies To Example Model

Returns the direction in degrees to a specified object.

object expression.DirTo (Object)

object expression    Required. An object expression that evaluates to an object in the Applies To list.

Object    Required VObject. An object of type Bot, Cell, or VPoint.

Remarks

The direction is measured relative to the Screen coordinate system. 0 degrees points in the positive direction of the y axis (North). A positive angle is measured from North towards the positive side of the x axis (West). A negative angle is measured from North towards the negative side of the x axis.

For the direction relative to the object's current heading, see AngleTo method.

When the Bounds property of the Screen object is set to wrapped mode, the calculated direction to an object is the shortest of all possible paths after accounting for wrapping around each of the Screen display edges.

Example

The following example uses the DirTo method to turn a Bot object in the direction away from another Bot.

direction = Bot.DirTo(OtherBot)
Bot.Dir direction+180. 'turns away from OtherBot