// Update is called once per frame
    void LateUpdate()
    {
        Vector2 targetPos;
        Vector2 offsetAccel = offsetPursuit.getSteering(target, offset, out targetPos);
        Vector2 sepAccel    = separation.getSteering(sensor.targets);

        steeringBasics.steer(offsetAccel + sepAccel);

        /* If we are still arriving then look where we are going, else look the same direction as our formation target */
        if (Vector2.Distance(transform.position, targetPos) > groupLookDist)
        {
            steeringBasics.lookWhereYoureGoing();
        }
        else
        {
            steeringBasics.lookAtDirection(target.rotation);
        }
    }
Example #2
0
    void LateUpdate()
    {
        Vector3 targetPos;
        // 偏移追随加速度  和  分隔加速度
        Vector3 offsetAccel = offsetPursuit.getSteering(target, offset, out targetPos);
        Vector3 sepAccel    = separation.GetSteering(sensor.targets);

        // 速度会  受到两个方面的影响
        steeringBasics.Steer(offsetAccel + sepAccel);

        /* 如果我们还在前往,那就要朝向我们要去的地方,其他的方向和我们的形成目标是一样的 */
        if (Vector3.Distance(transform.position, targetPos) > groupLookDist)
        {
            steeringBasics.LookWhereYoureGoing();
        }
        else
        {
            steeringBasics.lookAtDirection(target.rotation);
        }
    }