Follow Order

public class FollowOrder : Order

Use this order in situations, when unit should follow other unit. To setup FollowOrder, assing the FollowTarget field of class instance.

Example

// this example code running from Unit.cs component

Unit unit = this; // getting unit component, from which we run this code.
Unit otherUnit = FindObjectOfType<Unit>(); // suppose that there we setting up Unit component of other unit.

FollowOrder order = new FollowOrder(); // creating new FollowOrder here
order.FollowTarget = otherUnit.transform; // getting other unit transform and setting up it as moving target.

unit.AddOrder(order, false); // adding created order to unit orders list. Now unit will follow other unit.