Ejemplo n.º 1
0
    //Расчет сил
    public override Vector3 GetForce()
    {
        Vector3 force = Vector3.zero;

        Vector3 tv = leader.GetComponent <Rigidbody> ().velocity;

        tv.Normalize();
        tv *= LEADER_BEHIND_DIST;

        Vector3 ahead = leader.transform.position + tv;

        tv *= -1;

        Vector3 behind = leader.transform.position + tv;

        arrival.Target = behind;
        force          = arrival.GetForce();
        force         += GetSeparationForce();

        //Если лидер на пути, отойти в сторону
        if (IsOnLeaderSight(ahead))
        {
            force += GetEvadeForce(leader);
        }

        return(force);
    }