}                                           // The agent's rigid body

    private void Start()
    {
        DynamicAgents.Add(this);

        // Keep reference to rigid body
        Rb = GetComponent <Rigidbody2D>();

        // Get steering behaviours defined for this agent
        ISteeringBehaviour[] behaviours = GetComponents <ISteeringBehaviour>();

        // Add behaviours to dictionary using priority as key
        foreach (var b in behaviours)
        {
            if (!steeringBehaviours.ContainsKey(b.Priority))
            {
                steeringBehaviours.Add(b.Priority, new List <ISteeringBehaviour>());
            }

            steeringBehaviours[b.Priority].Add(b);
        }

        // Sort stering behaviours by priority (ascending)
        steeringBehaviours = steeringBehaviours.OrderBy(x => x.Key).ToDictionary(pair => pair.Key, pair => pair.Value);
    }
 private void OnDestroy()
 {
     DynamicAgents.Remove(this);
 }